Operator and syntax

Go comparison operators

Equality requires comparable operands; ordered comparisons are available for integers, floating-point numbers and strings (including defined types with those underlying types), not complex numbers. String ordering is byte-wise. Example output: 'true true true true true true'.

Formal Syntax & Structure

go syntaxgo
== != < <= > >=

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  fmt.Println(3 == 3, 3 != 4, 3 < 4, 3 <= 3, 4 > 3, 4 >= 4)}
Go Reference