GO Tutorial



OPERATORS IN GO


Operators in Go

Operators are symbols that perform operations on variables and values. Go supports various types of operators used in expressions.

1. Arithmetic Operators

Operator Description Example
+Additiona + b
-Subtractiona - b
*Multiplicationa * b
/Divisiona / b
%Modulus (remainder)a % b

2. Relational (Comparison) Operators

Operator Description Example
==Equal toa == b
!=Not equal toa != b
<Less thana < b
<=Less than or equal toa <= b
>Greater thana > b
>=Greater than or equal toa >= b

3. Logical Operators

Operator Description Example
&&Logical ANDa && b
||Logical ORa || b
!Logical NOT!a

4. Assignment Operators

Operator Description Example
=Assigna = b
+=Add and assigna += b
-=Subtract and assigna -= b
*=Multiply and assigna *= b
/=Divide and assigna /= b
%=Modulus and assigna %= b

5. Other Operators

  • & : Address of a variable (pointer).
  • * : Dereference pointer to get value.
  • << : Left shift.
  • >> : Right shift.
  • ^ : Bitwise XOR (exclusive OR).
  • ^= : Bitwise XOR and assign.
Note: Go does not support the increment (++) or decrement (--) operators as expressions; they can only be used as standalone statements.

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review