ubuntu / decorate

Go package containing various helpers to decorate errors with fewer lines of code in functions.
MIT License
3 stars 2 forks source link

govet failure: printf: non-constant format string in call to github.com/ubuntu/decorate.OnError (govet) #25

Closed jibel closed 2 weeks ago

jibel commented 3 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{})

There are two issues:

jibel commented 3 weeks ago

another option is to handle the number of arguments and use a different printf call whether args is empty or not.

jibel commented 2 weeks ago

resolved in main