Closed jibel closed 2 weeks ago
With the latest golangci-lint (1.60.1) the following code:
func Generate(policies []Policy, release string, root, currentSessions string) (ep []common.ExpandedPolicy, err error) { defer decorate.OnError(&err, gotext.Get("can't generate dconf expanded policies"))
generates this vet error:
Code sanity: internal/ad/admxgen/dconf/dconf.go#L58 printf: non-constant format string in call to github.com/ubuntu/decorate.OnError (govet)
The signature of OnError is func OnError(err *error, format string, args ...interface{})
func OnError(err *error, format string, args ...interface{})
There are two issues:
OnError
OnErrorf
another option is to handle the number of arguments and use a different printf call whether args is empty or not.
resolved in main
With the latest golangci-lint (1.60.1) the following code:
generates this vet error:
The signature of OnError is
func OnError(err *error, format string, args ...interface{})
There are two issues:
OnError
that accepts a format string should be calledOnErrorf
OnError
should be changed to remove the format string from the arguments and only accept a string.