Home>Article>Backend Development> Case sharing: Alipay payment based on golang
git clone git@github.com:yangliang4488/ali_pay_demo.git cd ali_pay_demo cp .env.example .env (.env 里请配置相关 appid 、公钥和私钥)go run main.go
When viper loads the envfile configuration file, refer to the following:
viper.SetConfigName(".env")viper.SetConfigType("env") // env 类型viper.AddConfigPath("./")if err := viper.ReadInConfig(); err != nil { fmt.Println(err) if _, ok := err.(viper.ConfigFileNotFoundError); ok { fmt.Println(".env 配置文件未找到") return }}
官方文档原文: viper.SetConfigType("json") // because there is no file extension in a stream of bytes, supported extensions are "json", "toml", "yaml", "yml", "properties", "props", "prop", "env", "dotenv"
For more golang related technical articles, please visit thegolangtutorial column!
The above is the detailed content of Case sharing: Alipay payment based on golang. For more information, please follow other related articles on the PHP Chinese website!