You can
print all the keys of a map using for loop.
Example
for key :=
range employees {
fmt.Println(key)
}
App.go
package main import "fmt" func main() { employees := map[int]string{ 1: "Krishna", 2: "Ram", 3: "Chamu", //Must have trailing comma } for key := range employees { fmt.Println(key) } }
Output
1
2
3
No comments:
Post a Comment