45 lines
910 B
Go
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
|
||
|
}
|