Files
  • main.go
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import "fmt"
func main() {    
color := map[string]map[string]string{    

        "R": map[string]string{
           "name":"Red",  //Note the double quote in name, value
           "example":"Cherry",
        },
           
        "B": map[string]string{
           "name":"Blue",  
           "example":"Sky",
        }, 
        
       "G": map[string]string{
           "name":"Green",  
           "example":"Grass",
        },    
}
     fmt.Println("Select a Primary Color: R / B / G")
     var colorCode string
     fmt.Scanf("%s", &colorCode)
 
     if value, isOK := color[colorCode]; isOK {
       fmt.Println("You love " +value["name"] +" "+ value["example"]) 
     } else {
          fmt.Println("Invalid entry OR Key not found in our record")
     }
}
go version go1.9.4 linux/amd64