Standard library / maps
maps.All()
Returns a key-value iterator. Order is unspecified and can differ across iterations. The iterator is not a snapshot. Expected stdout: 'a 2\n'.
Formal Syntax & Structure
go syntaxgo
func All[Map ~map[K]V, K comparable, V any](m Map) iter.Seq2[K, V]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| m | Map | Input map. |
Return Value
iter.Seq2[K, V]
Returns a key-value iterator. Order is unspecified and can differ across iterations. The iterator is not a snapshot.
Working Example
Example Snippetgo
package main
import ( "fmt" "maps")
func main() { m := map[string]int{"a": 2} for k, v := range maps.All(m) { fmt.Println(k, v) }}