Go Operators

In Go, operators are symbols or keywords used to perform various operations on variables and values. Here are some of the most commonly used operators in Go:

  1. Arithmetic operators:
  • + (addition)
  • - (subtraction)
  • * (multiplication)
  • / (division)
  • % (remainder)
  1. Comparison operators:
  • == (equal to)
  • != (not equal to)
  • < (less than)
  • > (greater than)
  • <= (less than or equal to)
  • >= (greater than or equal to)
  1. Logical operators:
  • && (logical AND)
  • || (logical OR)
  • ! (logical NOT)
  1. Bitwise operators:
  • & (bitwise AND)
  • | (bitwise OR)
  • ^ (bitwise XOR)
  • << (left shift)
  • >> (right shift)
  1. Assignment operators:
  • = (simple assignment)
  • += (add and assign)
  • -= (subtract and assign)
  • *= (multiply and assign)
  • /= (divide and assign)
  • %= (remainder and assign)
  • &= (bitwise AND and assign)
  • |= (bitwise OR and assign)
  • ^= (bitwise XOR and assign)
  • <<= (left shift and assign)
  • >>= (right shift and assign)
  1. Other operators:
  • & (address of)
  • * (dereference)
  • . (access struct fields)
  • : (case statement in switch)
  • ? (ternary operator)

These operators can be used in combination to create complex expressions and perform various operations on data in Go programs.