Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
sysulq committed Dec 25, 2024
1 parent 5744e32 commit 721946e
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions kod.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ type Kod struct {

config kodConfig

cfg *koanf.Koanf

hooker *hooks.Hooker

regs []*Registration
Expand Down Expand Up @@ -394,7 +392,7 @@ func (k *Kod) unmarshalConfig(key string, out interface{}) error {
return fmt.Errorf("set defaults: %w", err)
}

return k.cfg.Unmarshal(key, out)
return k.opts.koanf.Unmarshal(key, out)
}

// register adds the given implementations to the Kod instance.
Expand Down Expand Up @@ -454,7 +452,7 @@ func (k *Kod) loadConfig(filename string) error {
}
}

k.cfg = c
k.opts.koanf = c

return nil
}
Expand All @@ -466,14 +464,7 @@ func (k *Kod) parseConfig(filename string) error {
if err != nil {
return err
}
} else {
k.cfg = k.opts.koanf
}

err := k.cfg.Unmarshal("kod", &k.config)
if err != nil {
return fmt.Errorf("unmarshal config: %w", err)
}

return nil
return k.unmarshalConfig("kod", &k.config)
}

0 comments on commit 721946e

Please sign in to comment.