-
-
Notifications
You must be signed in to change notification settings - Fork 455
Expand file tree
/
Copy pathmap.go
More file actions
29 lines (23 loc) · 589 Bytes
/
Copy pathmap.go
File metadata and controls
29 lines (23 loc) · 589 Bytes
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
package main
import (
"fmt"
)
func main() {
myMap := make(map[string]string)
//Insertionn in a map
myMap["A"] = "apple"
myMap["B"] = "ball"
myMap["C"] = "cat"
//Traverse a map
fmt.Println("Printing Map..........")
for key, value := range myMap {
fmt.Println("Key: ", key, " Value: ", value)
}
//Delete a key-value pair from a map
//Deleting Key: "C" from map
fmt.Println("Deleting a key from Map..........")
delete(myMap, "C")
//Find the value associated with a key
fmt.Println("Finding a key from Map..........")
fmt.Println("Value for key 'A': ", myMap["A"])
}