Make "" mode being the same as debug mode (#1250)

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 "".
This commit is contained in:
Mario Kostelac 2018-02-23 01:09:33 +00:00 committed by Bo-Yi Wu
parent cbb1ee80b1
commit 5d3f30cfc8
2 changed files with 7 additions and 0 deletions

View File

@ -53,6 +53,9 @@ func SetMode(value string) {
default:
panic("gin mode unknown: " + value)
}
if value == "" {
value = DebugMode
}
modeName = value
}

View File

@ -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())