Standard library / maps
maps.EqualFunc()
Compares key sets and corresponding values using a caller-defined equality function; value types may differ. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func EqualFunc[M1 ~map[K]V1, M2 ~map[K]V2, K comparable, V1, V2 any](m1 M1, m2 M2, eq func(V1, V2) bool) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| m1 | M1 | First map to compare. |
| m2 | M2 | Second map to compare. |
| eq | func(V1, V2) bool | Equality callback, true for equivalent elements. |
Return Value
bool
Compares key sets and corresponding values using a caller-defined equality function; value types may differ.
Working Example
Example Snippetgo
package main
import ( "fmt" "maps")
func main() { fmt.Println(maps.EqualFunc(map[string]string{"a": "xx"}, map[string]int{"a": 2}, func(s string, n int) bool { return len(s) == n }))}