From 1b77f864198ddf73db1d46f92f7a8bf7738c1081 Mon Sep 17 00:00:00 2001 From: Gregor Noczinski Date: Sun, 27 Jan 2019 12:20:21 +0100 Subject: [PATCH] go fmt and lint --- filter_test.go | 2 +- init.go | 6 +++--- integration_test.go | 4 ++-- ruleReplaceAction.go | 6 +++--- ruleReplaceAction_test.go | 12 ++++++------ utils/fcgi/child.go | 2 +- utils/fcgi/fcgi.go | 11 ++++++++--- utils/test/testingCaddy.go | 6 +++--- utils/test/testingFcgiServer.go | 4 ++-- utils/test/testingHttpServer.go | 4 ++-- 10 files changed, 31 insertions(+), 26 deletions(-) diff --git a/filter_test.go b/filter_test.go index b65929d..1fbfaf3 100644 --- a/filter_test.go +++ b/filter_test.go @@ -3,10 +3,10 @@ package filter import ( "errors" "fmt" + "github.com/mholt/caddy/caddyhttp/fastcgi" . "gopkg.in/check.v1" "net/http" "regexp" - "github.com/mholt/caddy/caddyhttp/fastcgi" ) type filterTest struct { diff --git a/init.go b/init.go index fc38952..36da4fa 100644 --- a/init.go +++ b/init.go @@ -3,10 +3,10 @@ package filter import ( "github.com/mholt/caddy" "github.com/mholt/caddy/caddyhttp/httpserver" + "io/ioutil" + "os" "regexp" "strconv" - "os" - "io/ioutil" ) func init() { @@ -156,7 +156,7 @@ func evalReplacement(controller *caddy.Controller, target *rule) error { targetFilename := string(target.replacement[1:]) content, err := ioutil.ReadFile(targetFilename) if err != nil { - if ! os.IsNotExist(err) { + if !os.IsNotExist(err) { return controller.Errf("Could not read file provided in 'replacement' definition. Got: %v", err) } } else { diff --git a/integration_test.go b/integration_test.go index 451c2f2..d1a66f1 100644 --- a/integration_test.go +++ b/integration_test.go @@ -4,14 +4,14 @@ import ( "fmt" "github.com/echocat/caddy-filter/utils/test" . "github.com/echocat/gocheck-addons" + _ "github.com/mholt/caddy/caddyhttp/basicauth" _ "github.com/mholt/caddy/caddyhttp/errors" _ "github.com/mholt/caddy/caddyhttp/fastcgi" _ "github.com/mholt/caddy/caddyhttp/gzip" _ "github.com/mholt/caddy/caddyhttp/log" _ "github.com/mholt/caddy/caddyhttp/markdown" - _ "github.com/mholt/caddy/caddyhttp/redirect" _ "github.com/mholt/caddy/caddyhttp/proxy" - _ "github.com/mholt/caddy/caddyhttp/basicauth" + _ "github.com/mholt/caddy/caddyhttp/redirect" _ "github.com/mholt/caddy/caddyhttp/root" . "gopkg.in/check.v1" "io" diff --git a/ruleReplaceAction.go b/ruleReplaceAction.go index 485436a..c6a6f93 100644 --- a/ruleReplaceAction.go +++ b/ruleReplaceAction.go @@ -1,14 +1,14 @@ package filter import ( + "fmt" + "log" "net/http" + "os" "regexp" "strconv" "strings" "time" - "fmt" - "log" - "os" ) var paramReplacementPattern = regexp.MustCompile("\\{[a-zA-Z0-9_\\-.]+}") diff --git a/ruleReplaceAction_test.go b/ruleReplaceAction_test.go index 3287c35..bdf8f33 100644 --- a/ruleReplaceAction_test.go +++ b/ruleReplaceAction_test.go @@ -1,13 +1,13 @@ package filter import ( + "fmt" . "gopkg.in/check.v1" "net/http" "net/url" + "os" "regexp" "time" - "fmt" - "os" ) const ( @@ -58,7 +58,7 @@ func (s *ruleReplaceActionTest) Test_paramReplacer(c *C) { } rra := &ruleReplaceAction{ responseHeader: &http.Header{ - "A": []string{"c"}, + "A": []string{"c"}, "Last-Modified": []string{"Tue, 01 Aug 2017 15:13:59 GMT"}, }, } @@ -83,7 +83,7 @@ func (s *ruleReplaceActionTest) Test_paramReplacer(c *C) { func (s *ruleReplaceActionTest) Test_contextValueBy(c *C) { rra := &ruleReplaceAction{ responseHeader: &http.Header{ - "A": []string{"fromResponse"}, + "A": []string{"fromResponse"}, "Last-Modified": []string{"Tue, 01 Aug 2017 15:13:59 GMT"}, }, request: &http.Request{ @@ -105,11 +105,11 @@ func (s *ruleReplaceActionTest) Test_contextValueBy(c *C) { r, ok = rra.contextValueBy("now") c.Assert(ok, Equals, true) - c.Assert(r, Matches, yearString + ".*") + c.Assert(r, Matches, yearString+".*") r, ok = rra.contextValueBy("now:") c.Assert(ok, Equals, true) - c.Assert(r, Matches, yearString + ".*") + c.Assert(r, Matches, yearString+".*") r, ok = rra.contextValueBy("now:xxx2006-xxx") c.Assert(ok, Equals, true) diff --git a/utils/fcgi/child.go b/utils/fcgi/child.go index d57bf80..8c252ce 100644 --- a/utils/fcgi/child.go +++ b/utils/fcgi/child.go @@ -20,7 +20,7 @@ import ( "time" ) -// request holds the state for an in-progress request. As soon as it's complete, +// Request holds the state for an in-progress request. As soon as it's complete, // it's converted to an http.Request. type Request struct { pw *io.PipeWriter diff --git a/utils/fcgi/fcgi.go b/utils/fcgi/fcgi.go index bf2475f..c97fd7a 100644 --- a/utils/fcgi/fcgi.go +++ b/utils/fcgi/fcgi.go @@ -16,10 +16,15 @@ import ( "encoding/binary" "errors" "io" - "sync" "net/http" + "sync" ) +// A ResponseWriter interface is used by an HTTP handler to +// construct an HTTP response. +// +// A ResponseWriter may not be used after the Handler.ServeHTTP method +// has returned. type ResponseWriter interface { Header() http.Header Write([]byte) (int, error) @@ -141,8 +146,8 @@ func (rec *record) read(r io.Reader) (err error) { return nil } -func (r *record) content() []byte { - return r.buf[:r.h.ContentLength] +func (rec *record) content() []byte { + return rec.buf[:rec.h.ContentLength] } // writeRecord writes and sends a single record. diff --git a/utils/test/testingCaddy.go b/utils/test/testingCaddy.go index 656558b..c6e0d6e 100644 --- a/utils/test/testingCaddy.go +++ b/utils/test/testingCaddy.go @@ -1,14 +1,14 @@ package test import ( + "flag" "fmt" "github.com/mholt/caddy" - "flag" - "log" "io" + "log" + "os" "os/exec" "time" - "os" ) var ( diff --git a/utils/test/testingFcgiServer.go b/utils/test/testingFcgiServer.go index 8e841a4..eaf72a5 100644 --- a/utils/test/testingFcgiServer.go +++ b/utils/test/testingFcgiServer.go @@ -2,11 +2,11 @@ package test import ( "fmt" + "github.com/echocat/caddy-filter/utils/fcgi" + "log" "net" "net/http" "strings" - "github.com/echocat/caddy-filter/utils/fcgi" - "log" ) // TestingFcgiServer represents a http server for testing purposes diff --git a/utils/test/testingHttpServer.go b/utils/test/testingHttpServer.go index c96041f..956c1b3 100644 --- a/utils/test/testingHttpServer.go +++ b/utils/test/testingHttpServer.go @@ -1,12 +1,12 @@ package test import ( + "compress/gzip" "fmt" + "github.com/NYTimes/gziphandler" "net" "net/http" "strings" - "github.com/NYTimes/gziphandler" - "compress/gzip" ) // TestingHttpServer represents a http server for testing purposes