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:
parent
cbb1ee80b1
commit
5d3f30cfc8
3
mode.go
3
mode.go
@ -53,6 +53,9 @@ func SetMode(value string) {
|
|||||||
default:
|
default:
|
||||||
panic("gin mode unknown: " + value)
|
panic("gin mode unknown: " + value)
|
||||||
}
|
}
|
||||||
|
if value == "" {
|
||||||
|
value = DebugMode
|
||||||
|
}
|
||||||
modeName = value
|
modeName = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@ func TestSetMode(t *testing.T) {
|
|||||||
assert.Equal(t, TestMode, Mode())
|
assert.Equal(t, TestMode, Mode())
|
||||||
os.Unsetenv(ENV_GIN_MODE)
|
os.Unsetenv(ENV_GIN_MODE)
|
||||||
|
|
||||||
|
SetMode("")
|
||||||
|
assert.Equal(t, debugCode, ginMode)
|
||||||
|
assert.Equal(t, DebugMode, Mode())
|
||||||
|
|
||||||
SetMode(DebugMode)
|
SetMode(DebugMode)
|
||||||
assert.Equal(t, debugCode, ginMode)
|
assert.Equal(t, debugCode, ginMode)
|
||||||
assert.Equal(t, DebugMode, Mode())
|
assert.Equal(t, DebugMode, Mode())
|
||||||
|
Loading…
Reference in New Issue
Block a user