grpc-go: go vet says Errorf calls are all wrong, "constant 1 not a string in call to Errorf"

go vet seems assume that Errorf first arg would be format string

$ cat main.go 
package main

import (
    "google.golang.org/grpc"
    "google.golang.org/grpc/codes"
)

func main() {
    _ = grpc.Errorf(codes.Canceled, "i have nothing more to say")
}
$ go vet main.go 
main.go:9: constant 1 not a string in call to Errorf
exit status 1

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 15 (5 by maintainers)

Most upvoted comments

It’s kinda ridiculous that go vet won’t get fixed and you guys don’t wanna change your usage that fools go vet either… It’s a big pain in the ass for those of us who use go vet, which should be considered best practice.

If anyone else runs into this, here’s a workaround:

    errf := grpc.Errorf // Confuse `go vet' to not check this `Errorf' call. :(
    // See https://github.com/grpc/grpc-go/issues/90
    return errf(codes.Unimplemented, "RPC not yet implemented")

For posterity, this issue has been resolved in go vet in https://github.com/golang/go/issues/12294 and will be available in Go 1.7.