diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5e56e04 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/bin diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..c50a73b --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,11 @@ +run: + timeout: 5m + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - ineffassign + - staticcheck + - unused diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..cfc8d16 --- /dev/null +++ b/Makefile @@ -0,0 +1,13 @@ +GOBIN=$(shell pwd)/bin + +install-lint: + @if [ ! -f "$(GOBIN)/golangci-lint" ]; then \ + curl -sSfL -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.42.0; \ + fi + +lint: install-lint + @echo "golangci-lint run ./..." + @$(GOBIN)/golangci-lint run ./... + +test: + go test -race -failfast ./... diff --git a/mux_httpserver_test.go b/mux_httpserver_test.go index 907ab91..4333346 100644 --- a/mux_httpserver_test.go +++ b/mux_httpserver_test.go @@ -25,6 +25,8 @@ func TestSchemeMatchers(t *testing.T) { if err != nil { t.Fatalf("unexpected error getting from server: %v", err) } + defer resp.Body.Close() + if resp.StatusCode != 200 { t.Fatalf("expected a status code of 200, got %v", resp.StatusCode) } diff --git a/route.go b/route.go index 750afe5..29cc2ea 100644 --- a/route.go +++ b/route.go @@ -64,6 +64,7 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool { match.MatchErr = nil } + // nolint: ineffassign matchErr = nil return false }