fix(gin): data race warning for gin mode (#1580)

* fix: data race warning (#1180)

* Fix the tests

* refactor: remove unnecessary imports and optimize codebase

- Remove unnecessary import of `flag`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* test: refactor test assertions for mode settings

- Update test assertions for mode setting in `mode_test.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

---------

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Kostadin Plachkov
2024-05-08 04:13:36 +03:00
committed by GitHub
parent f5f5da8fa0
commit 7d147928ee
3 changed files with 17 additions and 25 deletions

View File

@ -10,6 +10,7 @@ import (
"runtime"
"strconv"
"strings"
"sync/atomic"
)
const ginSupportMinGoVer = 18
@ -17,7 +18,7 @@ const ginSupportMinGoVer = 18
// IsDebugging returns true if the framework is running in debug mode.
// Use SetMode(gin.ReleaseMode) to disable debug mode.
func IsDebugging() bool {
return ginMode == debugCode
return atomic.LoadInt32(&ginMode) == debugCode
}
// DebugPrintRouteFunc indicates debug log output format.