Interfaces

Interface equality and dynamic comparability

Interface values are equal when both are nil or their dynamic types are identical and their dynamic values are equal. Comparing identical dynamic types that are not comparable panics. Comparing an interface to nil is safe. Example output: 'false true'.

Formal Syntax & Structure

go syntaxgo
a == b

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  var a any = 3  var b any = int64(3)  fmt.Println(a == b, a == 3)}
Go Reference