go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

The configuration item supports the priority

Open yasin-wu opened this issue 2 years ago • 3 comments
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

yasin-wu avatar Apr 20 '23 02:04 yasin-wu

It's supported already. with the env tag.

kevwan avatar Apr 20 '23 15:04 kevwan

How to use? Thanks!

yasin-wu avatar Apr 23 '23 06:04 yasin-wu

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Apr 28 '24 01:04 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar Jul 29 '24 01:07 github-actions[bot]