In Go, an exported identifier is a name (such as a variable, constant, type, function, method, or struct field) that is accessible to code outside of the package in which it is declared. Go does not use access modifier keywords likeDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
public, private, or protected. Instead, it relies on a strict lexical rule based on character casing to determine visibility.
According to the Go language specification, an identifier is exported if and only if both of the following conditions are met:
- The first character of the identifier’s name is a Unicode uppercase letter (Unicode character category
Lu). - The identifier is declared in the package block, or it is a field name or method name.
Package-Level Declarations
At the package level, the casing of the first letter dictates whether other packages can import and reference the identifier.Struct Fields and Methods
Visibility rules apply independently to the fields and methods of a type. Exporting a struct type does not automatically export its internal fields or methods. Conversely, an unexported type can possess exported fields and methods. If an instance of an unexported type is exposed to another package (e.g., returned by an exported function), its exported fields and methods remain fully accessible.network.NewServer(), it can access the Address field and call the Start() method, even though the server type itself is unexported.
Interface Methods
Go fully supports declaring unexported methods within an exported interface. Because external packages cannot see or implement the unexported method, this mechanically restricts the interface so that it can only be implemented by types defined within the declaring package.Lexical Edge Cases
- Acronyms: Go conventions dictate that acronyms should be entirely uppercase (e.g.,
HTTP,URL) if exported, or entirely lowercase (e.g.,http,url) if unexported.Httpis valid and exported, but violates idiomatic Go style. - Underscores: An identifier starting with an underscore (e.g.,
_variable) is treated as lowercase and is unexported. The blank identifier (_) itself is never exported. - Non-Latin Characters: Go supports Unicode identifiers. A character like
Ω(Greek Capital Letter Omega) is in the UnicodeLucategory, soΩmegais an exported identifier.ω(lowercase) makesωmegaunexported.
Master Go with Deep Grasping Methodology!Learn More





