diff --git a/config/config.go b/config/config.go index c4aaa40..a0716d9 100644 --- a/config/config.go +++ b/config/config.go @@ -1,24 +1,23 @@ -// package config is responsible for the configuration of the application +// Package config is responsible for the configuration of the application package config // NOTE: actually make a package out of this if possible - lets try import ( "os" - "sync" "gopkg.in/yaml.v3" ) -var ( - instance *ESDICfg - once sync.Once -) +var instance *ESDICfg -type ESDICfg struct{} +type ESDICfg struct { + DefaultSim string `yaml:"default_sim"` + DefaultLayout string `yaml:"default_layout"` +} -func (cfg *ESDICfg) loadConfiguration() error { - file, err := os.ReadFile("./cfg.yaml") +func (cfg *ESDICfg) loadConfiguration(path string) error { + file, err := os.ReadFile(path) if err != nil { return err } @@ -31,10 +30,10 @@ func (cfg *ESDICfg) loadConfiguration() error { return nil } -func Setup() error { +func Setup(path string) error { instance = &ESDICfg{} - err := instance.loadConfiguration() + err := instance.loadConfiguration(path) if err != nil { return err } diff --git a/config/config.yaml b/config/config.yaml new file mode 100644 index 0000000..815d8fb --- /dev/null +++ b/config/config.yaml @@ -0,0 +1,2 @@ +default_sim: "iRacing" +default_layout: "layout.yaml"