← BYTES
Go·Starter·Ref: 10.1.18
In Go, how does a package decide whether an identifier (like a function or struct field name) is visible to code in other packages?
Have a question about this video? Mention reference 10.1.18 when you contact us.
a.By adding an explicit `public` or `private` keyword before it
b.By listing it in a special manifest file
c.Purely by the capitalization of its first letter: capitalized is exported (visible outside the package), lowercase is unexported (package-private)
d.All identifiers are always visible everywhere; Go has no access control at all
Go uses a simple, syntactic rule instead of access-modifier keywords: an identifier starting with an uppercase letter is exported and usable from other packages that import this one; one starting lowercase is unexported and only visible within its own package. This applies uniformly to functions, types, struct fields, constants, and variables.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES10118#Go