Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
go fmt and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
blaubaer committed Jan 27, 2019
1 parent ba69d96 commit 1b77f86
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion filter_test.go
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions init.go
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions integration_test.go
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions 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_\\-.]+}")
Expand Down
12 changes: 6 additions & 6 deletions 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 (
Expand Down Expand Up @@ -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"},
},
}
Expand All @@ -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{
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion utils/fcgi/child.go
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions utils/fcgi/fcgi.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions 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 (
Expand Down
4 changes: 2 additions & 2 deletions utils/test/testingFcgiServer.go
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions 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
Expand Down

0 comments on commit 1b77f86

Please sign in to comment.