Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改初始化的日志 #1667

Merged
merged 1 commit into from Mar 6, 2024
Merged

修改初始化的日志 #1667

merged 1 commit into from Mar 6, 2024

Conversation

andywu1998
Copy link
Contributor

目前代码里有根据gin.Mode()进行读不同的配置文件的操作,但针对不同的操作,输出都是同一个常量。所以这个PR改成变量。

@andywu1998
Copy link
Contributor Author

测试

注意 如果maintainer用的是mac或者linux,应该用export GIN_MODE="release",我用windows所以我执行的$Env:GIN_MODE="release"

不设置GIN_MODE

有warning

❯ go run .\main.go
您正在使用gin模式的debug环境名称,config的路径为config.yaml
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

GIN_MODE="release"

读了config.release.yaml

$Env:GIN_MODE="release"
 10785@andy  ~  code  gin-vue-admin  server  main 
❯ go run .\main.go
您正在使用gin模式的release环境名称,config的路径为config.release.yaml
panic: Fatal error config file: open config.release.yaml: The system cannot find the file specified. 


goroutine 1 [running]:
github.com/flipped-aurora/gin-vue-admin/server/core.Viper({0x0, 0x0, 0x60?})
        C:/Users/10785/code/gin-vue-admin/server/core/viper.go:57 +0x753
main.main()
        C:/Users/10785/code/gin-vue-admin/server/main.go:24 +0x2a
exit status 2

GIN_MODE="test"

读了config.test.yaml

$Env:GIN_MODE="test"   
 10785@andy  ~  code  gin-vue-admin  server  main 
❯ go run .\main.go    
您正在使用gin模式的test环境名称,config的路径为config.test.yaml
panic: Fatal error config file: open config.test.yaml: The system cannot find the file specified. 


goroutine 1 [running]:
github.com/flipped-aurora/gin-vue-admin/server/core.Viper({0x0, 0x0, 0x60?})
        C:/Users/10785/code/gin-vue-admin/server/core/viper.go:57 +0x753
main.main()
        C:/Users/10785/code/gin-vue-admin/server/main.go:24 +0x2a
exit status 2

GIN_MODE="debug"

效果和没设置一样
❯ $Env:GIN_MODE="debug"
 10785@andy  ~  code  gin-vue-admin  server  main 
❯ go run .\main.go
您正在使用gin模式的debug环境名称,config的路径为config.yaml
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.

@piexlmax piexlmax merged commit f4c2b50 into flipped-aurora:main Mar 6, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant