Fundamentals of Go Language

Fundamentals of the Go Language:

The fundamentals of the go language are given below:

Fundamentals of Go Language

Go tokens:

Tokens are the smallest individual units in the program. There are various tokens available in the go language; a few of them are given below:

  1. Keywords: Keywords are pre-defined segments in the go language. These are the reserved words, which are stored in the library of GoLang.
  2. Identifier: An identifier is a name that the developer in the program gives. It can be a variable name or function name or any user-defined functions in the go program.
  3. Variable: A variable is just a name given to a particular memory space in the storage, by which the Go program manipulates that variable.
  4. Constant: Constants are the fixed values in the program; they can't be changed during the execution process. These fixed values are also known as literals in the program.
  5. String: A string is a combination of two or more two characters. These characters can be a symbol, or a name, or any numbers. A string is always enclosed with a pair of double quotes or a pair of back ticks.
  6. Special character: Special characters are those who have special meaning in the go program.
  7. Symbols: Symbols are those, which represent specific things in the program. For example, &, *, and many more.

We will take a deep look at these topics one by one also in the next chapter.

Fundamentals of Go Language


Whitespace is the blank space in the program. This blank space can be tabs, newline characters, or comments in the go program. Space between two lines is also considered as whitespace.

A whole line can be considered whitespace only on one condition, i.e., when it contains the line comments. It is also known as a blank line. The compiler ignores this line during the compilation process.         

Whitespaces also use to distinguish one part of the statement from another part in the program that helps the compiler identify the elements in a go program statement.


var num1 int;

var num2 int;

sum = num1 + num2;

Here; in the above example,

In the first two lines, it is mandatory to give whitespace between the keyword and variable name. This space distinguishes the keywords and variable names and helps the compiler in identifying them.

But in the last statement, the whitespace is optional. The developer gives the whitespace just for providing the readability in the program.

Line separator:

Line separator points out the end of a single logical statement. Line separator is not required in the go language. Any statement or line of code in the go program does not require any special character to describe statement terminator like C language. The line is separated by a semi-colon (;) in the C language. While in the go language, the compiler put the semi-colon internally during the compilation.

Data Type:

Data type tells the type of the data to the compiler at the time of the go program's execution. With the help of data type, the compiler decides how much memory will assign to the variable.