多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 定义 在项目config目录下定义每个配置文件 mysql配置文件`config/mysql.go` ``` package config const ( MysqlHostName = "127.0.0.1" MysqlDb = "dbname" MysqlUser = "root" MysqlPassWord = "root" MysqlCharSet = "utf8" MysqlPrefix = "go_" ) ``` redis配置文件`config/redis.go` ``` package config const ( RedisAddr = "127.0.0.1:6379" RedisPassWord = "" RedisDb = 0 RedisPoolSize = 30 RedisMinIdleConns = 30 ) ``` 返回状态码配置文件`config/responseCode.go` ``` package config const ( Ok = 200 Error = 500 Logout = 600 ) ``` ## 使用 在需要使用的地方引入config包 ``` import "project/config" config.Ok ```