Skip to content

Commit

Permalink
[Update] documentation for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGalek committed Dec 16, 2024
1 parent 19483b7 commit 1826ab3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ package main
import "github.com/gouef/mode"

func main() {
m := mode.NewBasicMode()
m, err := mode.NewBasicMode()

if err != nil {
// do something
}

// some code
if m.IsRelease() {
if r, _ := m.IsRelease(); r {
// some code
}
}
Expand All @@ -40,19 +44,20 @@ func main() {
package main
import "github.com/gouef/mode"

modes := []string{"staging"}
mode := mode.NewMode(modes)

func main() {
modes := []string{"staging"}
m := mode.NewMode(modes)
m, err := mode.NewMode(modes)

if err != nil {
// do something
}

// some code
if m.IsRelease() {
if r, _ := m.IsRelease(); r {
m.EnableMode("staging")
}

if m.IsMode("staging") {
if sm, _ := m.IsMode("staging"); sm {
// some code
}
}
Expand Down
4 changes: 2 additions & 2 deletions mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Mode struct {
// NewBasicMode create basic Mode with debug, release, test
// Example:
//
// mode := mode.NewBaseMode()
// mode, err := mode.NewBaseMode()
func NewBasicMode() (*Mode, error) {
return NewMode(nil)
}
Expand All @@ -34,7 +34,7 @@ func NewBasicMode() (*Mode, error) {
// Example:
//
// modes := []string{"staging"}
// mode := mode.NewMode(modes)
// mode, err := mode.NewMode(modes)
func NewMode(additionalModes []string) (*Mode, error) {
mode := os.Getenv(EnvMode)
modes := []string{
Expand Down

0 comments on commit 1826ab3

Please sign in to comment.