Reputation: 1737
I like to name my types using Pascal case - starting with an upper case letter. In Go this implies the name is exported.
To avoid export, I've started to prefix the type name with undercsore instead of lower-casing the first letter.
E.g: Instead of
type Column struct{}
, I use type _Column struct{}
to avoid export.
I haven't seen this naming scheme used, but neither found any reason not to use it.
Since golint
accepts it without complaint, I guess this is OK?
Conclusion: Based on answers and comments I've decided to stay with lower-cased type names.
Upvotes: 4
Views: 924
Reputation: 11646
"I like to" and go don't super mix.
There are idiomatic bits and tooling enforced bits.
The community sticking to the standards makes for codebases that can be reasonably easy to read and comprehend by others.
I find this to be one of the best attributes of go.
Sure, channels and goroutines are nice.
Easily being able to read a codebase is often much more valuable.
Upvotes: 2
Reputation: 21288
I'd suggest using column
in preference to _Column
, on the basis that the style used by the standard libraries follow that naming convention.
This is not explicit in the Names section of the style guide, but based on the fact that underscores are generally discouraged, I'd say that using _Column
is, at best, not idiomatic.
Upvotes: 5