Underscore in constant and variable name

1,146 views
Skip to first unread message

Enze Chi

unread,
May 4, 2016, 2:04:26 AM5/4/16
to golang-nuts
Learning go and using go tool "stringer" to generate "String()" function.

The "golint" complains about the underscores in the variable and constant name, such as "_MyType_name" and "_MyType_index".

I think the underscores before "name" and "index" should be removed. Because It doesn't sounds good when the code from "golang" against its own "lint" tool. 


Tim K

unread,
May 4, 2016, 12:43:15 PM5/4/16
to golang-nuts
It's generally acceptable for machine generated code to break the rules (though it would be simple enough to fix the stringer tool). Quoting from this page:

"Code generated by the protocol buffer compiler is exempt from this rule. Human-written code is held to a higher standard than machine-written code."
Reply all
Reply to author
Forward
0 new messages