Type system

Go comparable values

Booleans, numbers, strings, pointers, channels and interfaces are comparable; arrays and structs require comparable elements or fields. Slices, maps and functions only support comparison to nil. Interface comparisons may panic when identical dynamic types are not comparable. Example output: 'true'.

Formal Syntax & Structure

go syntaxgo
x == y; x != y

Working Example

Example Snippetgo
package main
import (  "fmt")
func main() {  a := [2]int{1, 2}  b := [2]int{1, 2}  fmt.Println(a == b)}
Go Reference