golangci(lint) : more linters (#2870)
This commit is contained in:
		
							
								
								
									
										1
									
								
								.github/workflows/gin.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/gin.yml
									
									
									
									
										vendored
									
									
								
							@ -24,6 +24,7 @@ jobs:
 | 
			
		||||
          version: v1.42.1
 | 
			
		||||
          args: --verbose
 | 
			
		||||
  test:
 | 
			
		||||
    needs: lint
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        os: [ubuntu-latest, macos-latest]
 | 
			
		||||
 | 
			
		||||
@ -2,9 +2,22 @@ run:
 | 
			
		||||
  timeout: 5m
 | 
			
		||||
linters:
 | 
			
		||||
  enable:
 | 
			
		||||
  - asciicheck
 | 
			
		||||
  - depguard
 | 
			
		||||
  - dogsled
 | 
			
		||||
  - durationcheck
 | 
			
		||||
  - errcheck
 | 
			
		||||
  - errorlint
 | 
			
		||||
  - exportloopref
 | 
			
		||||
  - gci 
 | 
			
		||||
  - gofmt
 | 
			
		||||
  - goimports
 | 
			
		||||
  - misspell
 | 
			
		||||
  - nakedret
 | 
			
		||||
  - nilerr
 | 
			
		||||
  - nolintlint
 | 
			
		||||
  - revive
 | 
			
		||||
  - wastedassign
 | 
			
		||||
issues:
 | 
			
		||||
  exclude-rules:
 | 
			
		||||
  - linters:
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,7 @@
 | 
			
		||||
package binding
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"errors"
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -22,7 +23,7 @@ func (formBinding) Bind(req *http.Request, obj interface{}) error {
 | 
			
		||||
	if err := req.ParseForm(); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := req.ParseMultipartForm(defaultMemory); err != nil && err != http.ErrNotMultipart {
 | 
			
		||||
	if err := req.ParseMultipartForm(defaultMemory); err != nil && !errors.Is(err, http.ErrNotMultipart) {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
	if err := mapForm(obj, req.Form); err != nil {
 | 
			
		||||
 | 
			
		||||
@ -220,7 +220,8 @@ func (c *Context) Error(err error) *Error {
 | 
			
		||||
		panic("err is nil")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	parsedError, ok := err.(*Error)
 | 
			
		||||
	var parsedError *Error
 | 
			
		||||
	ok := errors.As(err, &parsedError)
 | 
			
		||||
	if !ok {
 | 
			
		||||
		parsedError = &Error{
 | 
			
		||||
			Err:  err,
 | 
			
		||||
@ -515,7 +516,7 @@ func (c *Context) initFormCache() {
 | 
			
		||||
		c.formCache = make(url.Values)
 | 
			
		||||
		req := c.Request
 | 
			
		||||
		if err := req.ParseMultipartForm(c.engine.MaxMultipartMemory); err != nil {
 | 
			
		||||
			if err != http.ErrNotMultipart {
 | 
			
		||||
			if !errors.Is(err, http.ErrNotMultipart) {
 | 
			
		||||
				debugPrint("error on parse multipart form array: %v", err)
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -23,10 +23,9 @@ import (
 | 
			
		||||
 | 
			
		||||
	"github.com/gin-contrib/sse"
 | 
			
		||||
	"github.com/gin-gonic/gin/binding"
 | 
			
		||||
	testdata "github.com/gin-gonic/gin/testdata/protoexample"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
 | 
			
		||||
	testdata "github.com/gin-gonic/gin/testdata/protoexample"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var _ context.Context = &Context{}
 | 
			
		||||
 | 
			
		||||
@ -6,6 +6,7 @@ package gin
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"bytes"
 | 
			
		||||
	"errors"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
@ -60,7 +61,8 @@ func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc {
 | 
			
		||||
				// condition that warrants a panic stack trace.
 | 
			
		||||
				var brokenPipe bool
 | 
			
		||||
				if ne, ok := err.(*net.OpError); ok {
 | 
			
		||||
					if se, ok := ne.Err.(*os.SyscallError); ok {
 | 
			
		||||
					var se *os.SyscallError
 | 
			
		||||
					if errors.As(ne, &se) {
 | 
			
		||||
						if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") {
 | 
			
		||||
							brokenPipe = true
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
@ -14,10 +14,9 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	testdata "github.com/gin-gonic/gin/testdata/protoexample"
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
	"google.golang.org/protobuf/proto"
 | 
			
		||||
 | 
			
		||||
	testdata "github.com/gin-gonic/gin/testdata/protoexample"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// TODO unit tests
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user