github.com/nozzle/golangci-lint@v1.49.0-nz3/test/testdata/govet.go (about) 1 //golangcitest:args -Egovet 2 //golangcitest:config_path testdata/configs/govet.yml 3 package testdata 4 5 import ( 6 "fmt" 7 "io" 8 "os" 9 ) 10 11 func GovetComposites() error { 12 return &os.PathError{"first", "path", os.ErrNotExist} // want "composites: io/fs\\.PathError struct literal uses unkeyed fields" 13 } 14 15 func GovetShadow(f io.Reader, buf []byte) (err error) { 16 if f != nil { 17 _, err := f.Read(buf) // want `shadow: declaration of .err. shadows declaration at line \d+` 18 if err != nil { 19 return err 20 } 21 } 22 // Use variable to trigger shadowing error 23 _ = err 24 return 25 } 26 27 func GovetNolintVet() error { 28 return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vet 29 } 30 31 func GovetNolintVetShadow() error { 32 return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vetshadow 33 } 34 35 func GovetPrintf() { 36 x := "dummy" 37 fmt.Printf("%d", x) // want "printf: fmt.Printf format %d has arg x of wrong type string" 38 } 39 40 func GovetStringIntConv() { 41 i := 42 42 fmt.Println("i = " + string(i)) // want "stringintconv: conversion from int to string yields a string of one rune, not a string of digits \\(did you mean fmt.Sprint\\(x\\)\\?\\)" 43 }