Trevor Pounds a653032409 Fix flaky cgo test failures. (#716)
Fixes flaky cgo test failures caused by duplicate printf
format checks in staticcheck and go vet that use slightly
different reporting formats.
2019-09-20 19:05:01 +03:00

39 lines
883 B
Go

//args: -Egovet
//config: linters-settings.govet.check-shadowing=true
package testdata
import (
"fmt"
"io"
"os"
)
func Govet() error {
return &os.PathError{"first", "path", os.ErrNotExist} // ERROR "composites: `os.PathError` composite literal uses unkeyed fields"
}
func GovetShadow(f io.Reader, buf []byte) (err error) {
if f != nil {
_, err := f.Read(buf) // ERROR "shadow: declaration of .err. shadows declaration at line \d+"
if err != nil {
return err
}
}
// Use variable to trigger shadowing error
_ = err
return
}
func GovetNolintVet() error {
return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vet
}
func GovetNolintVetShadow() error {
return &os.PathError{"first", "path", os.ErrNotExist} //nolint:vetshadow
}
func GovetPrintf() {
x := "dummy"
fmt.Printf("%d", x) // ERROR "printf: Printf format %d has arg x of wrong type string"
}