We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I write in a golang test file.code following
func TestViper(t *testing.T) { //func main() { viper.SetConfigName("config") viper.AddConfigPath("../config") viper.AddConfigPath(".") viper.AutomaticEnv() viper.SetConfigType("yaml") var configuration c.Configurations
if err := viper.ReadInConfig(); err != nil { log.Fatal(err) return } err := viper.Unmarshal(&configuration) if err != nil { log.Fatal(err) return } fmt.Println(configuration.Server.Port) fmt.Println(configuration.GameServer) fmt.Println(configuration.GOPATH) fmt.Println(configuration.EXAMPLE_VAR) viper.WatchConfig() viper.OnConfigChange(func(in fsnotify.Event) { if in.Op == fsnotify.Write { if err := viper.Unmarshal(&configuration); err != nil { log.Fatal(err) } fmt.Println("write") log.Printf("%#v", configuration) } }) select {}
}
#658 config.yaml server: port: 8080 gameServer: host: http://127.0.0.1/ token: 789 GOPATH: "variable from config.yaml" EXAMPLE_VAR: "path from config.yaml"
but I see nothing output
The text was updated successfully, but these errors were encountered:
wrong op.Name
Sorry, something went wrong.
No branches or pull requests
I write in a golang test file.code following
func TestViper(t *testing.T) {
//func main() {
viper.SetConfigName("config")
viper.AddConfigPath("../config")
viper.AddConfigPath(".")
viper.AutomaticEnv()
viper.SetConfigType("yaml")
var configuration c.Configurations
}
#658 config.yaml
server:
port: 8080
gameServer:
host: http://127.0.0.1/
token: 789
GOPATH: "variable from config.yaml"
EXAMPLE_VAR: "path from config.yaml"
after run test method ,I modify token from "789" to "123456"
but I see nothing output
The text was updated successfully, but these errors were encountered: