feat: automatically SetMode to TestMode when run go test. (#3139)
related issue: https://github.com/gin-gonic/gin/issues/3134
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
package gin
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@@ -54,7 +55,11 @@ func init() {
|
||||
// SetMode sets gin mode according to input string.
|
||||
func SetMode(value string) {
|
||||
if value == "" {
|
||||
value = DebugMode
|
||||
if flag.Lookup("test.v") != nil {
|
||||
value = TestMode
|
||||
} else {
|
||||
value = DebugMode
|
||||
}
|
||||
}
|
||||
|
||||
switch value {
|
||||
|
||||
Reference in New Issue
Block a user