Simple example of Map initialization in Go


The literal mapped values are specified using a colon-separated pair of key and value as shown in below example.

Example

package main

import "fmt"

var employee = map[string]int{"Mark":10,"Sandy":20}

func main() {
    fmt.Println(employee)
}

Output

map[Mark:10 Sandy:20]
Most Helpful This Week