chore: upgrade golangci-lint and fix golangci-lint error (#3278)

This commit is contained in:
thinkerou
2022-08-15 21:38:20 +08:00
committed by GitHub
parent 1b5ba251cf
commit b04917c53e
12 changed files with 74 additions and 60 deletions

View File

@ -152,7 +152,7 @@ func TestContextReset(t *testing.T) {
c.index = 2
c.Writer = &responseWriter{ResponseWriter: httptest.NewRecorder()}
c.Params = Params{Param{}}
c.Error(errors.New("test")) // nolint: errcheck
c.Error(errors.New("test")) //nolint: errcheck
c.Set("foo", "bar")
c.reset()
@ -1376,12 +1376,12 @@ func TestContextError(t *testing.T) {
assert.Empty(t, c.Errors)
firstErr := errors.New("first error")
c.Error(firstErr) // nolint: errcheck
c.Error(firstErr) //nolint: errcheck
assert.Len(t, c.Errors, 1)
assert.Equal(t, "Error #01: first error\n", c.Errors.String())
secondErr := errors.New("second error")
c.Error(&Error{ // nolint: errcheck
c.Error(&Error{ //nolint: errcheck
Err: secondErr,
Meta: "some data 2",
Type: ErrorTypePublic,
@ -1403,13 +1403,13 @@ func TestContextError(t *testing.T) {
t.Error("didn't panic")
}
}()
c.Error(nil) // nolint: errcheck
c.Error(nil) //nolint: errcheck
}
func TestContextTypedError(t *testing.T) {
c, _ := CreateTestContext(httptest.NewRecorder())
c.Error(errors.New("externo 0")).SetType(ErrorTypePublic) // nolint: errcheck
c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) // nolint: errcheck
c.Error(errors.New("externo 0")).SetType(ErrorTypePublic) //nolint: errcheck
c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) //nolint: errcheck
for _, err := range c.Errors.ByType(ErrorTypePublic) {
assert.Equal(t, ErrorTypePublic, err.Type)
@ -1424,7 +1424,7 @@ func TestContextAbortWithError(t *testing.T) {
w := httptest.NewRecorder()
c, _ := CreateTestContext(w)
c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") // nolint: errcheck
c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") //nolint: errcheck
assert.Equal(t, http.StatusUnauthorized, w.Code)
assert.Equal(t, abortIndex, c.index)