From 6993a0b90012ccd5eeb1b41aac02bb31b0281cc9 Mon Sep 17 00:00:00 2001 From: Rutger Broekhoff Date: Thu, 14 Nov 2024 00:32:31 +0100 Subject: Why is Go so terrible --- config.go | 23 ++++++++++++----------- icalproxy.go | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/config.go b/config.go index 746e437..9070ae9 100644 --- a/config.go +++ b/config.go @@ -15,14 +15,14 @@ type userToken struct { Salt []byte `json:"salt"` } -type jsonURL url.URL +type jsonURL struct{ v url.URL } func (u *jsonURL) UnmarshalText(v []byte) error { parsed, err := url.Parse(string(v)) if err != nil { return err } - *u = jsonURL(*parsed) + u.v = *parsed return nil } @@ -44,16 +44,8 @@ func printConfig(cfg *config) { b64 := base64.StdEncoding log.Print("Loaded configuration: ") + log.Print(" Calendar URL: ", cfg.CalendarURL.v.String()) log.Print(" HTTP Port: ", cfg.Port) - log.Print(" User Tokens:") - for user, token := range cfg.UserTokens { - log.Print(" User ", user, ":") - log.Print(" Hash: ", b64.EncodeToString(token.Hash)) - log.Print(" Salt: ", b64.EncodeToString(token.Salt)) - } - if len(cfg.UserTokens) == 0 { - log.Print(" ") - } log.Print(" Ignoring:") for _, entry := range cfg.Ignore.LocationRegexes { log.Printf(" Events with locations matching %s", entry.String()) @@ -64,6 +56,15 @@ func printConfig(cfg *config) { if len(cfg.Ignore.LocationRegexes)+len(cfg.Ignore.SummaryRegexes) == 0 { log.Printf(" ") } + log.Print(" User Tokens:") + for user, token := range cfg.UserTokens { + log.Print(" User ", user, ":") + log.Print(" Hash: ", b64.EncodeToString(token.Hash)) + log.Print(" Salt: ", b64.EncodeToString(token.Salt)) + } + if len(cfg.UserTokens) == 0 { + log.Print(" ") + } } func loadConfigFrom(filename string) config { diff --git a/icalproxy.go b/icalproxy.go index 9ca1b33..60a9bac 100644 --- a/icalproxy.go +++ b/icalproxy.go @@ -16,7 +16,7 @@ func main() { printConfig(&cfg) handler := handler{ - calURL: url.URL(cfg.CalendarURL), + calURL: url.URL(cfg.CalendarURL.v), ignore: cfg.Ignore, tokens: cfg.UserTokens, } -- cgit v1.2.3