From 2b428230b2e6f1b8e77f08ab96a1137ec915b561 Mon Sep 17 00:00:00 2001 From: sneak Date: Sat, 10 Oct 2020 15:08:37 +0000 Subject: [PATCH] switch to gofumpt --- Makefile | 6 +++--- cmd/httpd/main.go | 8 +++++--- httpserver/main.go | 9 ++++----- httpserver/middlewares.go | 3 --- httpserver/routes.go | 2 -- 5 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 609eea9..5014ac0 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,12 @@ default: debug commit: fmt lint git commit -a -# get goimports with: -# go get golang.org/x/tools/cmd/goimports # get golangci-lint with: # go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.31.0 +# get gofumports with: +# go get mvdan.cc/gofumpt/gofumports fmt: - goimports -l -w . + gofumports -l -w . golangci-lint run --fix lint: diff --git a/cmd/httpd/main.go b/cmd/httpd/main.go index 7dd2ab3..b3f4502 100644 --- a/cmd/httpd/main.go +++ b/cmd/httpd/main.go @@ -6,9 +6,11 @@ import ( "git.eeqj.de/sneak/gohttpserver/httpserver" ) -var Appname string = "CHANGEME" -var Version string -var Buildarch string +var ( + Appname string = "CHANGEME" + Version string + Buildarch string +) func main() { os.Exit(httpserver.Run(Appname, Version, Buildarch)) diff --git a/httpserver/main.go b/httpserver/main.go index b26de23..11da37b 100644 --- a/httpserver/main.go +++ b/httpserver/main.go @@ -122,12 +122,11 @@ func (s *server) serve() int { go s.serveUntilShutdown() for range s.ctx.Done() { - //aforementioned clean shutdown upon main context - //cancellation + // aforementioned clean shutdown upon main context + // cancellation } s.cleanShutdown() return s.exitCode - } func (s *server) cleanupForExit() { @@ -171,7 +170,7 @@ func (s *server) configure() { viper.AddConfigPath(fmt.Sprintf("/etc/%s", s.appname)) // call multiple times to add many search paths: viper.AddConfigPath(fmt.Sprintf("$HOME/.config/%s", s.appname)) - //viper.SetEnvPrefix(strings.ToUpper(s.appname)) + // viper.SetEnvPrefix(strings.ToUpper(s.appname)) viper.AutomaticEnv() viper.SetDefault("DEBUG", "false") @@ -250,7 +249,7 @@ func (s *server) setupLogging() { logger := zerolog.New(multi).With().Timestamp().Logger().With().Caller().Logger() s.log = &logger - //log.Logger = logger + // log.Logger = logger if viper.GetBool("debug") { zerolog.SetGlobalLevel(zerolog.DebugLevel) diff --git a/httpserver/middlewares.go b/httpserver/middlewares.go index cf6024a..cbdefb6 100644 --- a/httpserver/middlewares.go +++ b/httpserver/middlewares.go @@ -66,11 +66,9 @@ func (s *server) LoggingMiddleware() func(http.Handler) http.Handler { Int("status", lrw.statusCode). Int("latency_ms", int(latency.Milliseconds())). Send() - }() next.ServeHTTP(lrw, r) - }) } } @@ -118,5 +116,4 @@ func (s *server) MetricsAuthMiddleware() func(http.Handler) http.Handler { }, }, ) - } diff --git a/httpserver/routes.go b/httpserver/routes.go index 19f2682..861bafa 100644 --- a/httpserver/routes.go +++ b/httpserver/routes.go @@ -12,7 +12,6 @@ import ( ) func (s *server) routes() { - s.router = chi.NewRouter() // the mux .Use() takes a http.Handler wrapper func, like most @@ -93,5 +92,4 @@ func (s *server) routes() { r.Get("/metrics", http.HandlerFunc(promhttp.Handler().ServeHTTP)) }) } - }