A:增加启动自动引入依赖库版本以及信息
This commit is contained in:
1 parent
e0484efa2e
commit
6443cefb6a
10 files changed
+875
-120
No files matched your search
@@ -0,0 +1,45 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"rear/internal/config"
|
||||
)
|
||||
|
||||
// 示例:展示如何使用开发阶段标识
|
||||
|
||||
func exampleDevelopmentCheck() {
|
||||
// 方法1:使用 IsDevelopment() 函数
|
||||
if config.IsDevelopment() {
|
||||
fmt.Println("当前处于开发阶段")
|
||||
// 执行开发阶段特有的代码
|
||||
enableDebugFeatures()
|
||||
loadTestData()
|
||||
} else {
|
||||
fmt.Println("当前处于生产阶段")
|
||||
// 执行生产阶段的代码
|
||||
optimizeForProduction()
|
||||
}
|
||||
|
||||
// 方法2:使用 IsProduction() 函数
|
||||
if config.IsProduction() {
|
||||
fmt.Println("生产环境配置启用")
|
||||
// 生产环境特有的配置
|
||||
}
|
||||
}
|
||||
|
||||
func enableDebugFeatures() {
|
||||
fmt.Println("- 启用调试功能")
|
||||
fmt.Println("- 启用详细日志")
|
||||
fmt.Println("- 启用性能监控")
|
||||
}
|
||||
|
||||
func loadTestData() {
|
||||
fmt.Println("- 加载测试数据")
|
||||
fmt.Println("- 启用模拟接口")
|
||||
}
|
||||
|
||||
func optimizeForProduction() {
|
||||
fmt.Println("- 启用性能优化")
|
||||
fmt.Println("- 禁用调试信息")
|
||||
fmt.Println("- 启用缓存")
|
||||
}
|
||||
Reference in new issue
Block a user