Categories
Go My Go Tutorial

Range Over Slice and Map

package main

import "fmt"

func main() {
  kvs := map[string]string{"1":"shan kuo","2":"Hoi Leng","3":"Choi Yan","4":"Evelyn Chan"}
  for k, v := range kvs {
    fmt.Printf("%s -> %s\n",k,v)
  }
}

https://repl.it/join/gdzplzna-shankuo

 go build
 ./main
1 -> shan kuo
2 -> Hoi Leng
3 -> Choi Yan
4 -> Evelyn Chan