From 1aa59f1b0b98abe567d6a28ce7b3bed90160ec49 Mon Sep 17 00:00:00 2001 From: pando85 Date: Thu, 18 Nov 2021 19:26:53 +0100 Subject: [PATCH] Fix long lines (#2) Using [golines](https://github.com/segmentio/golines): `golines -w .` --- cmd/whatismyip.go | 3 ++- internal/setting/app.go | 18 +++++++++++++++--- router/generic_test.go | 13 ++++++++++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/cmd/whatismyip.go b/cmd/whatismyip.go index a0c71f9..2b55d65 100644 --- a/cmd/whatismyip.go +++ b/cmd/whatismyip.go @@ -112,7 +112,8 @@ func runTLSServer() { go func() { log.Printf("Starting TLS server listening on %s", setting.App.TLSAddress) - if err := tlsServer.ListenAndServeTLS(setting.App.TLSCrtPath, setting.App.TLSKeyPath); err != nil && !errors.Is(err, http.ErrServerClosed) { + if err := tlsServer.ListenAndServeTLS(setting.App.TLSCrtPath, setting.App.TLSKeyPath); err != nil && + !errors.Is(err, http.ErrServerClosed) { log.Fatal(err) } log.Printf("Stopping TLS server...") diff --git a/internal/setting/app.go b/internal/setting/app.go index ac9a3b9..5b6c680 100644 --- a/internal/setting/app.go +++ b/internal/setting/app.go @@ -36,11 +36,23 @@ func Setup() { city := flag.String("geoip2-city", "", "Path to GeoIP2 city database") asn := flag.String("geoip2-asn", "", "Path to GeoIP2 ASN database") template := flag.String("template", "", "Path to template file") - address := flag.String("bind", defaultAddress, "Listening address (see https://pkg.go.dev/net?#Listen)") - addressTLS := flag.String("tls-bind", "", "Listening address for TLS (see https://pkg.go.dev/net?#Listen)") + address := flag.String( + "bind", + defaultAddress, + "Listening address (see https://pkg.go.dev/net?#Listen)", + ) + addressTLS := flag.String( + "tls-bind", + "", + "Listening address for TLS (see https://pkg.go.dev/net?#Listen)", + ) tlsCrtPath := flag.String("tls-crt", "", "When using TLS, path to certificate file") tlsKeyPath := flag.String("tls-key", "", "When using TLS, path to private key file") - trustedHeader := flag.String("trusted-header", "", "Trusted request header for remote IP (e.g. X-Real-IP)") + trustedHeader := flag.String( + "trusted-header", + "", + "Trusted request header for remote IP (e.g. X-Real-IP)", + ) ver := flag.Bool("version", false, "Output version information and exit") flag.Parse() diff --git a/router/generic_test.go b/router/generic_test.go index 525c0a2..f331067 100644 --- a/router/generic_test.go +++ b/router/generic_test.go @@ -9,7 +9,18 @@ import ( ) func TestIP4RootFromCli(t *testing.T) { - uas := []string{"", "curl", "wget", "libwww-perl", "python", "ansible-httpget", "HTTPie", "WindowsPowerShell", "http_request", "Go-http-client"} + uas := []string{ + "", + "curl", + "wget", + "libwww-perl", + "python", + "ansible-httpget", + "HTTPie", + "WindowsPowerShell", + "http_request", + "Go-http-client", + } req, _ := http.NewRequest("GET", "/", nil) req.Header.Set("X-Real-IP", testIP.ipv4)