Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
minhduc140583 committed Aug 24, 2024
1 parent 6c5aadf commit 23484cf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ type RootConfig struct {

func main() {
env := os.Getenv("ENV")
var conf RootConfig
var cfg RootConfig
// "authentication" is the directory, which contains source code
// "configs" is the directory, which contains config.yaml and config-sit.yaml
config.LoadConfigWithEnv("authentication", "configs", env, &conf, "config")
log.Println("config ", conf)
config.LoadConfigWithEnv("authentication", "configs", env, &cfg, "config")
log.Println("config ", cfg)

var conf2 RootConfig
config.Load(&conf2, "configs/config")
Expand Down
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func LoadConfigWithEnv(parentPath string, directory string, env string, c interf
// BindEnvs function will bind ymal file to struc model
func BindEnvs(conf interface{}, parts ...string) error {
ifv := reflect.Indirect(reflect.ValueOf(conf))
ift := reflect.TypeOf(ifv)
ift := ifv.Type()
num := min(ift.NumField(), ifv.NumField())
for i := 0; i < num; i++ {
v := ifv.Field(i)
Expand Down

0 comments on commit 23484cf

Please sign in to comment.