From 98542afd2488a4fb3f00031b19fbe843c7349ed2 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 30 Jul 2023 20:05:22 -0400 Subject: [PATCH] linting --- main.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/main.go b/main.go index 33bbff6..a0e19b4 100644 --- a/main.go +++ b/main.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "net/http" "os" "os/signal" @@ -20,9 +19,9 @@ import ( "gopkg.in/yaml.v2" ) -func load_config(filename string) (*Config, error) { +func loadConfig(filename string) (*Config, error) { u := &Config{} - yamlFile, err := ioutil.ReadFile(filename) + yamlFile, err := os.ReadFile(filename) if err != nil { return nil, err } @@ -53,7 +52,7 @@ func main() { } debug := os.Getenv("WATCH_DEBUG") - watchusers, err := load_config(file) + watchusers, err := loadConfig(file) if err != nil { log.Fatal(err) } @@ -89,27 +88,35 @@ func main() { <-c log.Info("trying to shutdown cleanly") endFn() - server.Shutdown(ctx) + err := server.Shutdown(ctx) + if err != nil { + log.Warn("error shutting down tilde server", "error", err) + } }() wg.Add(1) go func() { - server.ListenAndServe() + err := server.ListenAndServe() + if err != nil { + log.Warn("error shutting down web server", "error", err) + } wg.Done() log.Info("watch web server shutdown") }() wg.Add(1) go func() { - a.run(ctx) + err := a.run(ctx) + if err != nil { + log.Warn("error shutting down update server", "error", err) + } + wg.Done() log.Info("watch updater shutdown") }() log.Info("watch running") wg.Wait() log.Info("shut down") - - return } func (watch *Watch) server() http.Handler { @@ -150,7 +157,7 @@ func (watch *Watch) run(ctx context.Context) error { case <-ticker.C: for i, v := range watch.Tildes { if v.Update { - err := watch.run_update(i, v) + err := watch.runUpdate(i, v) if err != nil { log.Warn("error running update", "error", err) } @@ -164,7 +171,7 @@ func (watch *Watch) run(ctx context.Context) error { } } -func (watch *Watch) run_update(token string, reg Registration) error { +func (watch *Watch) runUpdate(token string, reg Registration) error { if reg.Domain == "" || reg.IPAddr == "" { return fmt.Errorf("invalid registration for update %v: %v", reg.Domain, reg.IPAddr) }