package config import ( "encoding/json" "io/ioutil" "os" ) type config struct { Hostnames []string `json:"hosts"` Port int `json:"port"` AllowLocalPath bool `json:"allow-local-path"` Auth bool `json:"auth"` RootPath string `json:"root-path"` } var Config config func ReadConfig() error { file, err := os.Open("config.json") if err != nil { return err } else { defer file.Close() } content, _ := ioutil.ReadAll(file) json.Unmarshal(content, &Config) return nil }