Briefly explain the Operators in Go Programming Language | Go Programming Tutorial
In this article, you will learn more about the Operators in the Go programming language.
Bitwise Operators:
There are 6 Bitwise operators in the Go Programming language which works at a bit level. It is used to perform bit-by-bit operations. The bitwise operators are:
- & (bitwise AND): The operands are converted into bits and then perform the AND on every bit of two numbers. If both the bits are 1, then only the result is 1.
- | (bitwise OR): The operands values are converted into bits and then perform the OR operation on every bit. If any of the two bits is 1, then the result of OR is 1.
- ^ (bitwise XOR): The operands values are converted into bits and then execute the XOR on every bit of two numbers. If the values of the two bits are different, then the result is 1.
- << (left shift): It takes two numbers, the left shifts the bits of the first number, and the second number decides the number of places to shift.
- >> (right shift): It takes two numbers, right shifts the bits of the first number, and the second number decides the number of places to shift.
- &^ (AND NOT): This is a bit, clear operator.
Assignment Operators:
Assignment Operators are used to assigning a value to a variable. The left side of the assignment operator is a variable and the right side of the assignment operator is a value. The value on the right side must be of the same data type as the variable on the left side. Different types of assignments are:
- “=” (Simple Assignment): It is used to assign the value on the right side to the variable.
- “+=” (Add Assignment): This operator is a combination of the addition and assignment operator. This operator first adds the current value on the other value and then assigns the result to the variable on the left side.
- “-=” (Subtract Assignment): This operator is a combination of the subtraction and assignment operator. This operator first subtracts the value of the other number and then assigns the result to the variable on the left side.
- “*=” (Multiply Assignment): This operator is a combination of the multiplication and assignment operator. This operator multiplies the value with another value and then assigns the result to the variable on the left side.
Similarly, there are so many bitwise operators exists such as Division Assignment, Modulus Assignment, Bitwise AND Assignment, Bitwise Exclusive OR)
Misc Operators:
- &: It returns the address of the variable
- *: It provides a pointer to a variable.
- <-: The name of this operator is received.


