Go comparison operators

In the example, we will show you how to use below comparison operators in Go with an example.

< less than

<= less than or equal to

> greater than

>= greater than or equal to

== equal to

!= not equal to

Comparison operators are used to compare values. These operators always result in a boolean value.

Go comparison operators

In the code example, we have four expressions. These expressions compare integer values.


package main

import "fmt"

func main() {

    fmt.Println(2 < 3)
    fmt.Println(3 == 4)
    fmt.Println(3 >= 3)
    fmt.Println(4 != 3)
}

Output:

true
false
true
true

Free Spring Boot Tutorial - 5 Hours Full Course


Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course