Radar · Go · Archive · Week 28 · Jul 6 – 12, 2026
maps: add Same func
Nice to knowstdlib
- What changed
- The
mapspackage now has aSamegeneric function that reports whether two maps refer to the same underlying data structure. - Production impact
- The source does not say.
- Try it
- Use
maps.Same(m1, m2)to compare map identities. - Source
- github.com/golang/go/issues/78456
Understand it, then run it
After the change ships
go · the proposal's code; it does not compile until the change ships
// This does not compile until the Same function is shipped in Go 1.28.
package main
import (
"fmt"
"maps"
)
func main() {
s := map[int]struct{}{1: {}, 2: {}}
t := s
u := map[int]struct{}{1: {}, 2: {}}
fmt.Println(maps.Same(s, t)) // true
fmt.Println(maps.Same(s, u)) // false
}
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed