Protobuf: add comments, remove underscores to be "more go-like"

Created on 8 Sep 2015  路  5Comments  路  Source: golang/protobuf

Running golint across our .pb.go files yields quite a number of issues. It would be great to either have golint ignore .pb.go files by default, or to have this library generate code golint will happily find acceptable. Key issues:

  • Id -> ID
  • "exported thing X should have comment or be unexported"
  • "don't use underscores in Go names; struct field XXX_unrecognized should be XXXUnrecognized"

Thank you!

Prior art: https://github.com/golang/protobuf/issues/53

Most helpful comment

The problem is not really about the .pb.go files. It is that you end up using the generated service interfaces in your app code and then your actual app code doesn't pass the linter anymore because of it.

I think it should be considered a real issue to have the official protobuf package triggering warnings from the official linter package.

All 5 comments

Don't run golint on generated .pb.go files. There will be endless things flagged, and in general we only care about golint on human-written code. The protocol compiler can't be smart in the way that a human can.

@dsymonds Would you consider a PR that ignores .pb.go files in golint? At the moment, I'm running golint ./folder instead of on each file individually.

Nope. Just grep them out of the output or do something like find ./folder | grep -v '\.pb\.go$' | xargs golint.

Seems like that oughtn't be necessary for known exceptions, but you got it, boss.

The problem is not really about the .pb.go files. It is that you end up using the generated service interfaces in your app code and then your actual app code doesn't pass the linter anymore because of it.

I think it should be considered a real issue to have the official protobuf package triggering warnings from the official linter package.

Was this page helpful?
0 / 5 - 0 ratings