CalAnonSync/src/calanonsync/settings.go

40 lines
595 B
Go
Raw Normal View History

2018-03-31 18:52:32 +02:00
package main
import (
"encoding/json"
"os"
"strings"
2018-03-31 18:52:32 +02:00
)
type ServerSettings struct {
URL string
Username string
Password string
}
type Settings struct {
EWS ServerSettings
CalDAV ServerSettings
Anonymize struct {
Title string
}
}
func LoadSettings() Settings {
f, err := os.Open("calanonsync.json")
if err != nil {
panic(err)
}
settings := Settings{}
err = json.NewDecoder(f).Decode(&settings)
if err != nil {
panic(err)
}
if settings.CalDAV.URL != "" && strings.HasSuffix(settings.CalDAV.URL, "/") {
settings.CalDAV.URL += "/"
}
2018-03-31 18:52:32 +02:00
return settings
}