golangci-lint/test/testdata/errorlint_errorf.go
Vladimir Evgrafov 796a958805
Add go-errorlint (#1420)
* Add errorlint

* Add errorlint config example
2020-10-09 15:42:48 +03:00

27 lines
817 B
Go

//args: -Eerrorlint
//config: linters-settings.errorlint.errorf=true
package testdata
import (
"errors"
"fmt"
)
type customError struct{}
func (customError) Error() string {
return "oops"
}
func wraps() {
err := errors.New("oops")
fmt.Errorf("error: %w", err)
fmt.Errorf("error: %v", err) // ERROR "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors"
fmt.Errorf("%v %v", err, err) // ERROR "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors"
fmt.Errorf("error: %s", err.Error()) // ERROR "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors"
customError := customError{}
fmt.Errorf("error: %s", customError.Error()) // ERROR "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors"
strErr := "oops"
fmt.Errorf("%v", strErr)
}