Junior — Middle
How can a variable be designated as private in programming?
sobes.tech AI
Answer from AI
In Go (Golang), the access level to variables is determined by the case of the first letter of the name. If the variable name (or function, type, struct field) starts with an uppercase letter — it is exported (public), if with a lowercase — private (accessible only within the package).
Example:
package example
var PublicVar = 1 // public variable
var privateVar = 2 // private variable
func PublicFunc() {} // public function
func privateFunc() {} // private function
Thus, to make a variable private, simply start its name with a lowercase letter.