Sha256: 7afa05d6dcd1d66903ed94233bd00555b2b31cd72f5f3cbe0864afff94cbc842
Contents?: true
Size: 698 Bytes
Versions: 3
Compression:
Stored size: 698 Bytes
Contents
package global import ( "encoding/json" "fmt" "os" ) // ConfigStruct defines a config object usually created on startup type ConfigStruct struct { SysLogIP string `json:"syslog_server"` RootFolder string } // Config is a global instance of the config var Config ConfigStruct // LoadConfig load the config file from the given folder func LoadConfig(config string, rootfolder string) error { fmt.Println("Loading Config: ", config) file, err := os.Open(config) if err != nil { return fmt.Errorf("Unable to open config") } decoder := json.NewDecoder(file) Config = ConfigStruct{} err = decoder.Decode(&Config) Config.RootFolder = rootfolder fmt.Println(Config) return nil }
Version data entries
3 entries across 3 versions & 1 rubygems