package main import ( "encoding/json" log "github.com/sirupsen/logrus" "io/ioutil" "strings" ) type configStaticHtml struct { Dir string StaticUrl string StripPrefix string } type configuration struct { Host string Port string DSN string TlsCert string TlsKey string Static []configStaticHtml Debug bool Session struct { //TODO: figure what is this intended for Guest bool Year int //how many years Month int //how many years Day int //how many years } } var configFile = "config.json" var config = configuration{} func (m *configuration) readConfig() (e error) { log.Printf("read Path config from %s", configFile) body, e := ioutil.ReadFile(configFile) if e != nil { log.Fatal("Cannot read config from " + configFile) return } e = json.Unmarshal(body, m) //TODO: check config before proceed further return } func (m *configuration) getAvatarPath() (ret string) { for _, v := range m.Static { if strings.ToLower(v.Dir) == "avatar" { return v.Dir //found it } } return "" }