...

Web Technologies - Go Language

Back to Course

Lesson Description


Lession - #355 Go-Operators


Go - Operators

An operator is an image that advises the compiler to perform explicit numerical or sensible controls. Go language is wealthy in inherent administrators and gives the accompanying sorts of operators −

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Bitwise Operators
  • Assignment Operators
  • Miscellaneous Operators


Arithmetic Operators

Following table shows every one of the math administrators upheld by Go language. Accept variable A holds 10 and variable B holds 20 then − Show Examples

Operator Description Example
+ Adds two operands A + B gives 30
- Subtracts second operand from the first A - B gives -10
* Multiplies both operands A * B gives 200
/ Divides the numerator by the denominator B / A gives 2
% Modulus operator; gives the remainder after an integer division. B % A gives 0
++ Increment operator. It increases the integer value by one. A++ gives 11
-- Decrement operator. It decreases the integer value by one. A-- gives 9


Relational Operators

The accompanying table records every one of the social administrators upheld by Go language. Accept variable A holds 10 and variable B holds 20, then −
Operator Description Example
== It checks assuming that the upsides of two operands are equivalent or not; if indeed, the condition turns out to be valid. (A == B>
is not true.
!= It checks assuming the upsides of two operands are equivalent or not; in the event that the qualities are not equivalent, then, at that point, the condition turns out to be valid. (A != B>
is true.
> It checks assuming the worth of left operand is more noteworthy than the worth of right operand; if indeed, the condition turns out to be valid. (A > B>
is not true.
< It checks in the event that the worth of left operand is not exactly the worth of the right operand; if indeed, the condition turns out to be valid. (A < B>
is true.
>= It checks in the event that the worth of the left operand is more noteworthy than or equivalent to the worth of the right operand; if indeed, the condition turns out to be valid. (A >= B>
is not true.
<= It checks assuming the worth of left operand is not exactly or equivalent to the worth of right operand; if indeed, the condition turns out to be valid. (A <= B>
is true.

Logical Operators

The accompanying table records every one of the intelligent administrators upheld by Go language. Expect variable A holds 1 and variable B holds 0, then −
Operator Description Example
&& Called Logical AND administrator. In the event that both the operands are non-zero, condition turns out to be valid. (A && B>
is false.
|| Called Logical OR Operator. If any of the two operands is non-zero, then condition becomes true. (A || B>
is true.
! Called Logical NOT Operator. Use to inverts the sensible condition of its operand. On the off chance that a condition is valid then Logical NOT administrator will make misleading. !(A && B>
is true.


Bitwise Operators

The bitwise AND administrator ( &>
analyzes each piece of the main operand to the comparing piece of the subsequent operand. Assuming the two pieces are 1, the comparing result bit is set to 1. In any case, the relating result bit is set to 0.

Assignment Operators

A assignment operator is the operator used to dole out another worth to a variable, property, occasion or indexer component in C# programming language. Task operators can likewise be utilized for legitimate activities, for example, bitwise consistent tasks or procedure on necessary operands and Boolean operands.

Miscellaneous Operators

Incidental administrators comprise of three operands, the different administrators are as per the following: Operator (?:>
- > Conditional Expression (likewise an option for if-else condition>
. It is a ternary operator(means administrator works on three operands>