Standard library / reflect
reflect.MapIter.Key()
Returns the current key after a successful Next; do not call after exhaustion. Expected stdout: 'a\n'.
Formal Syntax & Structure
go syntaxgo
func (iter *MapIter) Key() ValueReturn Value
Value
Returns the current key after a successful Next; do not call after exhaustion.
Working Example
Example Snippetgo
package main
import ( "fmt" "reflect")
func main() { m := reflect.ValueOf(map[string]int{"a": 7}) it := m.MapRange() it.Next() fmt.Println(it.Key().String())}