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) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| m1 | M1 | First map to compare. |
| m2 | M2 | Second 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{}))}