GoGronkh/config/config.go
Andreas Mieke f6259a8160 Rewirte of parser and server
Changed database layout and using Go path for source now
2015-09-26 00:33:55 +02:00

45 lines
910 B
Go

package config
import (
"encoding/json"
"io/ioutil"
)
type Config struct {
DatabaseConnection string
EpisodeRegex string
YoutubeKey string
GronkhUrl string
ImageDirectory string
ImageWebDirectory string
UseSocket bool
BindAddress string
BindSocket string
PiwikURL string
PiwikID int
PiwikToken string
SiteUrl string
AssetsDirectory string
TemplatesDirectory string
}
var C Config
func LoadConfig(path string) (error) {
file, e := ioutil.ReadFile(path)
if e != nil {
return e
}
e = json.Unmarshal(file, &C)
return e
}
func WriteConfig(path string) (error) {
jason, err := json.Marshal(C)
if err != nil {
return err
}
err = ioutil.WriteFile(path, jason, 0755)
return err
}