Skip to content

Commit

Permalink
chore: fix linter errors (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
unknwon committed Oct 19, 2022
1 parent 9e2c44f commit 9047801
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
5 changes: 1 addition & 4 deletions .golangci.yml
Expand Up @@ -4,16 +4,13 @@ linters-settings:

linters:
enable:
- deadcode
- unused
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- nakedret
- gofmt
- rowserrcheck
Expand Down
4 changes: 2 additions & 2 deletions recovery.go
Expand Up @@ -7,9 +7,9 @@ package flamego
import (
"bytes"
"fmt"
"io/ioutil"
"log"
"net/http"
"os"
"runtime"

"github.com/flamego/flamego/inject"
Expand Down Expand Up @@ -109,7 +109,7 @@ pre {
// Print this much at least. If we can't find the source, it won't show.
_, _ = fmt.Fprintf(buf, "%s:%d (0x%x)\n", file, line, pc)
if file != lastFile {
data, err := ioutil.ReadFile(file)
data, err := os.ReadFile(file)
if err != nil {
continue
}
Expand Down
11 changes: 6 additions & 5 deletions router.go
Expand Up @@ -145,11 +145,12 @@ type Route struct {
// addition to the request path.
//
// For example:
// f.Get("/", ...).Headers(
// "User-Agent", "Chrome", // Loose match
// "Host", "^flamego\.dev$", // Exact match
// "Cache-Control", "", // As long as "Cache-Control" is not empty
// )
//
// f.Get("/", ...).Headers(
// "User-Agent", "Chrome", // Loose match
// "Host", "^flamego\.dev$", // Exact match
// "Cache-Control", "", // As long as "Cache-Control" is not empty
// )
//
// Subsequent calls to Headers() replace previously set matches.
func (r *Route) Headers(pairs ...string) *Route {
Expand Down
22 changes: 11 additions & 11 deletions static_test.go
Expand Up @@ -25,7 +25,7 @@ func TestStatic(t *testing.T) {

t.Run("serve with GET", func(t *testing.T) {
resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/.editorconfig", nil)
req, err := http.NewRequest(http.MethodGet, "/.editorconfig", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -37,7 +37,7 @@ func TestStatic(t *testing.T) {

t.Run("serve with HEAD", func(t *testing.T) {
resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodHead, "/.editorconfig", nil)
req, err := http.NewRequest(http.MethodHead, "/.editorconfig", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -49,7 +49,7 @@ func TestStatic(t *testing.T) {

t.Run("404 with POST", func(t *testing.T) {
resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodPost, "/.editorconfig", nil)
req, err := http.NewRequest(http.MethodPost, "/.editorconfig", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -73,7 +73,7 @@ func TestStatic_Options(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/hello.txt", nil)
req, err := http.NewRequest(http.MethodGet, "/hello.txt", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand Down Expand Up @@ -142,7 +142,7 @@ func TestStatic_Options(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodHead, "/", nil)
req, err := http.NewRequest(http.MethodHead, "/", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -164,7 +164,7 @@ func TestStatic_Options(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodHead, "/.editorconfig", nil)
req, err := http.NewRequest(http.MethodHead, "/.editorconfig", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestStatic_Options(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/.editorconfig", nil)
req, err := http.NewRequest(http.MethodGet, "/.editorconfig", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -229,7 +229,7 @@ func TestStatic_Options(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/.editorconfig", nil)
req, err := http.NewRequest(http.MethodGet, "/.editorconfig", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand Down Expand Up @@ -260,7 +260,7 @@ func TestStatic_Redirect(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/public/", nil)
req, err := http.NewRequest(http.MethodGet, "/public/", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -278,7 +278,7 @@ func TestStatic_Redirect(t *testing.T) {
))

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "/public", nil)
req, err := http.NewRequest(http.MethodGet, "/public", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand All @@ -292,7 +292,7 @@ func TestStatic_Redirect(t *testing.T) {
f.Use(Static())

resp := httptest.NewRecorder()
req, err := http.NewRequest(http.MethodGet, "http://localhost:2830//example.com%2f..", nil)
req, err := http.NewRequest(http.MethodGet, "http://localhost:2830//example.com%2f..", http.NoBody)
assert.Nil(t, err)

f.ServeHTTP(resp, req)
Expand Down

0 comments on commit 9047801

Please sign in to comment.