So it should be lowercase if it's not imported. And that's strange to import something from a main package. But, that's look very strange for me to use lowercase for the first of a struct/class from experience with other languages. What way is idiomatic?
This isn't a question of what's idiomatic, if an identifier starts with a lowercase letter, it's not exported and therefore can only be accessed from the declaring package (directly), and if an identifier starts with an uppercase letter (Unicode class "Lu"), it's exported and can be referred to from any package. For details, see Spec: Exported identifiers. This was a design decision, which I personally like (it keeps the source clean, and "They even have semantic effect: the visibility of a name outside a package is determined by whether its first character is upper case" – Effective Go: Names).
The main
package is special: you can't import the main package, so it doesn't matter how you name your identifiers in the main
package, no one (no package other than the main
) will refer to them / use them.
See more releavant blog posts: