github.com/be-b10g/golangci-lint@v1.17.2/test/testdata/govet.go (about)

     1  //args: -Egovet
     2  //config: linters-settings.govet.check-shadowing=true
     3  package testdata
     4  
     5  import (
     6  	"io"
     7  	"os"
     8  )
     9  
    10  func Govet() error {
    11  	return &os.PathError{"first", "path", os.ErrNotExist} // ERROR "composites: `os.PathError` composite literal uses unkeyed fields"
    12  }
    13  
    14  func GovetShadow(f io.Reader, buf []byte) (err error) {
    15  	if f != nil {
    16  		_, err := f.Read(buf) // ERROR "shadow: declaration of .err. shadows declaration at line \d+"
    17  		if err != nil {
    18  			return err
    19  		}
    20  	}
    21  	// Use variable to trigger shadowing error
    22  	_ = err
    23  	return
    24  }
    25  
    26  func GovetNolintVet() error {
    27  	return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vet
    28  }
    29  
    30  func GovetNolintVetShadow() error {
    31  	return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vetshadow
    32  }