From 394e8aa27e9c21e4be7216f5e8a63cc09e30250a Mon Sep 17 00:00:00 2001 From: Jim Walker Date: Mon, 7 Mar 2016 15:45:32 -0500 Subject: [PATCH] add example for ranging through keys --- examples/range/range.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/range/range.go b/examples/range/range.go index ecb874f..3f1255e 100644 --- a/examples/range/range.go +++ b/examples/range/range.go @@ -34,6 +34,11 @@ func main() { fmt.Printf("%s -> %s\n", k, v) } + // `range` can also iterate over just the keys of a map. + for k := range kvs { + fmt.Println("key:", k) + } + // `range` on strings iterates over Unicode code // points. The first value is the starting byte index // of the `rune` and the second the `rune` itself.