Standard library / maps

maps.Equal()

Reports equal key sets and corresponding values using ==. Nil and empty maps compare equal; no special handling for NaN keys. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func Equal[M1, M2 ~map[K]V, K, V comparable](m1 M1, m2 M2) bool

Parameters & Attributes

NameTypeDescription
m1M1First map to compare.
m2M2Second map to compare.

Return Value

bool

Reports equal key sets and corresponding values using ==. Nil and empty maps compare equal; no special handling for NaN keys.

Working Example

Example Snippetgo
package main
import (  "fmt"  "maps")
func main() {  fmt.Println(maps.Equal(map[string]int(nil), map[string]int{}))}
Go Reference