Keywords in GoLang

Rules for naming an identifier in the go language:

There are several rules for creating an identifier in the go language. The Go language strictly follows these rules. If the identifier does not create within the rules, the developer will get an error during the compilation process. Here are some rules are given below for naming the identifiers:

Rule no. 1:

Only alphabetic characters, digits, and underscore are allowed for naming an identifier in the go language. The developer can’t use punctuation characters like @, &, #, %, *, and many more for creating the identifiers. The alphabets can be in lower case or upper case.

Rule no. 2:

The go language is a case-sensitive programming language, so the upper case and lower case variables will be distinct in the go program.

Rule no. 3:

An identifier name must start with lower case (a to z) or upper case (A to Z) alphabets or with an underscore (_). Except for the first letter of the identifier, the remaining letters can be in any alphabets (in lower case or upper case) or underscore (_) or digits (0 to 9).

Rule no. 4:

A keyword can’t be the name of an identifier in the go language. The developer can’t create an identifier by the keywords’ name because keywords are pre-defined in the go language library, and each keyword has its description.

Rule no. 5:

The developer can give the name of the identifier as long as he wants. There is no limit on the character’s length in creating the identifier in the go program. But it is not an intelligent work to give a very long name to an identifier. The recommended length for creating an identifier name is 4 to 15 letters only.

Valid Identifiers name:

Abc

Invalid identifiers name:

123abc

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store