Skip to content

Commit

Permalink
Make "" mode being the same as debug mode (gin-gonic#1250)
Browse files Browse the repository at this point in the history
Not setting mode explicitly sets gin into debug mode, but it does not
make it possible to retrieve gin mode as Debug since it's set to "".

(cherry picked from commit 5d3f30c)
  • Loading branch information
mario-at-intercom authored and Tony Yip committed Apr 28, 2018
1 parent 7e39afe commit 328317a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func SetMode(value string) {
default:
panic("gin mode unknown: " + value)
}
if value == "" {
value = DebugMode
}
modeName = value
}

Expand Down
4 changes: 4 additions & 0 deletions mode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func TestSetMode(t *testing.T) {
assert.Equal(t, TestMode, Mode())
os.Unsetenv(ENV_GIN_MODE)

SetMode("")
assert.Equal(t, debugCode, ginMode)
assert.Equal(t, DebugMode, Mode())

SetMode(DebugMode)
assert.Equal(t, debugCode, ginMode)
assert.Equal(t, DebugMode, Mode())
Expand Down

0 comments on commit 328317a

Please sign in to comment.