go-zero
go-zero copied to clipboard
The configuration item supports the priority
trafficstars
The configuration item supports the priority,like viper Environment variable > file > default; for example:
type Database struct {
Host string `json:",optional,default=127.0.0.1:27017"`
}
config file
Database:
Host: 127.0.0.1:27011
os.Setenv("Database. Host","127.0.0.2:27011") Then, Database.Host=127.0.0.2:27011,if env is nil,Database.Host=127.0.0.1:27011
It's supported already. with the env tag.
How to use? Thanks!
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.