Initialise and evaluate a map from strings to strings in Go

This is an example Go program which demonstrates initialising a map from strings to strings and then looping over it using range.

package main

import (
        "fmt"
)

func main() {
        m := map[string]string{
                "ceiling": "天井",
                "floor":   "床",
                "wall":    "壁",
        }
        for key, value := range m {
                fmt.Printf("%s is %s in Japanese.\n", key, value)
        }
}

(download)

The output of the example looks like this:

ceiling is 天井 in Japanese.
floor is 床 in Japanese.
wall is 壁 in Japanese.


Copyright © Ben Bullock 2009-2018. All rights reserved. For comments, questions, and corrections, please email Ben Bullock (benkasminbullock@gmail.com) or use the discussion group at Google Groups. / Privacy / Disclaimer