diff --git a/config/config.go b/config/config.go new file mode 100644 index 0000000..5d8f0df --- /dev/null +++ b/config/config.go @@ -0,0 +1,32 @@ +package config + +import ( + "encoding/json" + "os" +) + +// Config contains all needed configurations +type Config struct { + DatabaseUser string + DatabaseHost string + DatabasePassword string + DatabaseName string + file *os.File +} + +// LoadConfig from path +func LoadConfig(path string) (*Config, error) { + file, err := os.Open(path) + if err != nil { + return nil, err + } + + decoder := json.NewDecoder(file) + configuration := Config{} + err = decoder.Decode(&configuration) + if err != nil { + return nil, err + } + + return &configuration, nil +}