Variables in Golang
Naming Conventions + Different Ways of Declaring Variables
1 min readMay 29, 2020
Golang Naming Conventions
- camelCase — camelCase is a naming convention in which the first letter of each word in a compound word is capitalized EXCEPT for the first letter
- PascalCase — PascalCase is a naming convention in which the first letter of each word in a compound word is capitalized
- Capitalize acronyms — ex. HTTP, DNS, URL
Variable names are always important when programming, but especially so when programming in Golang.
- Variables declared at the package level will not be exported to other packages if the variable starts with a lowercase letter
- In contrast if a variable declared at the package level starts with an uppercase letter it will be exported to other packages
- Variables in Go always have to be used. If there are any unused variables the compiler will throw an error.