Junior — Middle
What is the difference between the names of structures starting with a lowercase letter and those starting with an uppercase letter?
sobes.tech AI
Answer from AI
In Go (Golang), struct names starting with a capital letter are exported from the package and accessible in other packages. Names starting with a lowercase letter are unexported and only visible within the same package.
Example:
package example
type Person struct { // exported struct
Name string
}
type employee struct { // unexported struct
id int
}
Thus, if a struct starts with a capital letter, it can be used outside the package, which is important for organizing a public API. If it starts with a lowercase letter, the struct is hidden inside the package.