gospt/internal/config/config.go
2023-01-08 21:08:51 -08:00

38 lines
779 B
Go

package config
import (
"path/filepath"
"github.com/cristalhq/aconfig"
"github.com/cristalhq/aconfig/aconfigyaml"
)
var Values struct {
ClientId string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
}
func LoadConfig(configDir string) {
yamlDecoder := aconfigyaml.New()
loader := aconfig.LoaderFor(&Values, aconfig.Config{
AllowUnknownFields: true,
AllowUnknownEnvs: true,
AllowUnknownFlags: true,
SkipFlags: true,
DontGenerateTags: true,
MergeFiles: true,
EnvPrefix: "",
FlagPrefix: "",
Files: []string{
filepath.Join(configDir, "client.yml"),
},
FileDecoders: map[string]aconfig.FileDecoder{
".yml": yamlDecoder,
},
})
if err := loader.Load(); err != nil {
panic(err)
}
}