Tokens in Go

December 27, 2021, Learn eTutorial

In programming languages, tokens are the basic components of the source code. Tokens make the vocabulary for a programming language.
For example, the following Go statement consists of 6 tokens –

fmt.Println("Welcome to Learn eTutorials!!")

The individual tokens are −

GO : Tokens

In the Go programming language, tokens are classified into five. They are…

  1.     Keywords:

    In a programming language, a keyword is a predefined word that has some special meaning. Keywords are used to perform some predefined actions. Keywords are not allowed to be used as an identifier. Go programming language supports 25 keywords. They are:

    GO : Tokens
       Learn more about Keywords in Golang.
  2.     Identifiers: 

    In programming languages, identifiers are the user-defined names or entities of the components in the program. An identifier is a sequence of one or more letters and digits that are used to identify the components. In Go language, an identifier can be a constant, function name, variable name, package name, types, or statement labels.

    Learn more about Identifiers in Golang.
  3.     Operators:

    Operators are the basic component in every programming language. Operators are used to performing different types of operations on operands (variables and values). The Go programming language provides different types of operators based on their functionality, and they are as follows:

    1. Arithmetic operators
    2. Comparison operators
    3. Logical operators
    4. Assignment operators
    5. BitWise operators
    Learn more about Operators in Golang.
  4.     Variables:

    In Go programming language variables are used to store values in memory. A variable is a storage location, with a specific type and an associated name. Naming a variable properly is an important part of software development.

    Learn more about Variables in Golang.
  5.     Literals or Constants:

    In the Go programming language, the literals are the fixed values in the program that may not change during the program execution. Literals are also called constants. There are different types of literal available in the Go programming language. They are:

    1. integer literals
    2. floating-point literals
    3. string literals
    Learn more about Constants in Golang.