package config import ( "encoding/json" "log" "waterservice/internal/app/storage" ) type config struct { Influx struct { Host string `json:"host"` Port int `json:"port"` Token string `json:"token"` Org string `json:"org"` Bucket string `json:"bucket"` } `json:"influx"` } var ( logger log.Logger = *log.Default() store storage.Storage config_cache config ) func init() { logger.SetFlags(log.Llongfile | log.Ltime) } func SetConfigFilePath(path string) { store.SetPath(path) res, err := store.Read() if err != nil { logger.Print("unable to read config") return } err = json.Unmarshal(res, &config_cache) if err != nil { logger.Print("unable to unmarshal json to object") } } func GetConfig() config { return config_cache }