Skip to content

Commit

Permalink
feat: add golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fifsky committed May 22, 2023
1 parent abafd6b commit 4beeac7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,23 @@ jobs:
test:
strategy:
matrix:
go-version: [1.16,1.17,1.18]
go-version: ["1.19","1.20","1.21"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set up Golang ${{ matrix.go-version }}
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
id: go

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52

- name: Test
env:
TZ: Asia/Shanghai
Expand Down
14 changes: 7 additions & 7 deletions debug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package gee

import (
"fmt"
"io/ioutil"
"io"
"net/http"
"testing"

Expand All @@ -17,14 +17,14 @@ func TestDebugRoute(t *testing.T) {
{
w := performRequest(router, "GET", "/debug/pprof/?debug_token=058759a8c4d920576348854616a58f3f")
assert.Equal(t, http.StatusOK, w.Code)
body, _ := ioutil.ReadAll(w.Body)
body, _ := io.ReadAll(w.Body)
assert.Contains(t, string(body), "<body>")
}

{
w := performRequest(router, "GET", "/debug/metrics?debug_token=058759a8c4d920576348854616a58f3f")
assert.Equal(t, http.StatusOK, w.Code)
body, _ := ioutil.ReadAll(w.Body)
body, _ := io.ReadAll(w.Body)
fmt.Println(string(body))
assert.Contains(t, string(body), "go_info")
}
Expand All @@ -40,14 +40,14 @@ func TestDebugRouteWithPath(t *testing.T) {
{
w := performRequest(router, "GET", "/example/debug/pprof/?debug_token=058759a8c4d920576348854616a58f3f")
assert.Equal(t, http.StatusOK, w.Code)
body, _ := ioutil.ReadAll(w.Body)
body, _ := io.ReadAll(w.Body)
assert.Contains(t, string(body), "<body>")
}

{
w := performRequest(router, "GET", "/example/debug/metrics?debug_token=058759a8c4d920576348854616a58f3f")
assert.Equal(t, http.StatusOK, w.Code)
body, _ := ioutil.ReadAll(w.Body)
body, _ := io.ReadAll(w.Body)
fmt.Println(string(body))
assert.Contains(t, string(body), "go_info")
}
Expand All @@ -64,14 +64,14 @@ func TestDebugWithRouteGroup(t *testing.T) {
{
w := performRequest(router, "GET", "/example/debug/pprof/?debug_token=058759a8c4d920576348854616a58f3f")
assert.Equal(t, http.StatusOK, w.Code)
body, _ := ioutil.ReadAll(w.Body)
body, _ := io.ReadAll(w.Body)
assert.Contains(t, string(body), "<body>")
}

{
w := performRequest(router, "GET", "/example/debug/metrics?debug_token=058759a8c4d920576348854616a58f3f")
assert.Equal(t, http.StatusOK, w.Code)
body, _ := ioutil.ReadAll(w.Body)
body, _ := io.ReadAll(w.Body)
fmt.Println(string(body))
assert.Contains(t, string(body), "go_info")
}
Expand Down
5 changes: 2 additions & 3 deletions test_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"net/url"
Expand Down Expand Up @@ -110,12 +109,12 @@ func (r *TestRequest) doRequest(method string, contentType string, body io.Reade
req := r.Request.Clone(context.Background())
req.Method = method
if body != nil {
bb, err = ioutil.ReadAll(body)
bb, err = io.ReadAll(body)
if err != nil {
return nil, err
}

req.Body = ioutil.NopCloser(bytes.NewReader(bb))
req.Body = io.NopCloser(bytes.NewReader(bb))
}

if method == http.MethodPost {
Expand Down

0 comments on commit 4beeac7

Please sign in to comment.