Skip to content

Instantly share code, notes, and snippets.

@presmihaylov
Last active April 12, 2020 11:51
Show Gist options
  • Save presmihaylov/6b47c8664cfbbe3be1a653d81d1bcd07 to your computer and use it in GitHub Desktop.
Save presmihaylov/6b47c8664cfbbe3be1a653d81d1bcd07 to your computer and use it in GitHub Desktop.
package configfx
// imports
// ApplicationConfig ...
type ApplicationConfig struct {
Address string `yaml:"address"`
}
// Config ...
type Config struct {
ApplicationConfig `yaml:"application"`
}
// ProvideConfig to fx
func ProvideConfig() *Config {
conf := Config{}
data, err := ioutil.ReadFile("config/base.yaml")
// handle error
err = yaml.Unmarshal([]byte(data), &conf)
// handle error
return &conf
}
// example continues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment