Six rules you must always consider and follow each time you declare a variable name.
1. A variable name must start with a letter or an underscore character (_)
2. A variable name cannot start with a digit
3. A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z
, 0-9
, and _
)
4. Variable names are case-sensitive (age, Age, and AGE are three different variables)
5. There is no limit on the length of the variable name
6. A variable name cannot contain spaces
7. The variable name cannot be any Go keywords
Multi-Word Variable Names:
1. Camel Case: Each word, except the first, starts with a capital letter
Syntex: myVariableName = "John"
2. Pascal Case: Each word starts with a capital letter
Syntex: MyVariableName = "John"
3. Snake Case: Each word is separated by an underscore character
Syntex: my_variable_name = "John"
Comments
Post a Comment