update:SetMode function (#2321)

This commit is contained in:
bestgopher 2020-04-16 22:31:58 +08:00 committed by GitHub
parent 4f208887e1
commit a4e947a356
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
mode.go
View File

@ -50,8 +50,12 @@ func init() {
// SetMode sets gin mode according to input string. // SetMode sets gin mode according to input string.
func SetMode(value string) { func SetMode(value string) {
if value == "" {
value = DebugMode
}
switch value { switch value {
case DebugMode, "": case DebugMode:
ginMode = debugCode ginMode = debugCode
case ReleaseMode: case ReleaseMode:
ginMode = releaseCode ginMode = releaseCode
@ -60,9 +64,7 @@ func SetMode(value string) {
default: default:
panic("gin mode unknown: " + value) panic("gin mode unknown: " + value)
} }
if value == "" {
value = DebugMode
}
modeName = value modeName = value
} }