Last active
August 23, 2017 21:02
-
-
Save davidsnt/b700a053629b2dd141130ad7deecb8f7 to your computer and use it in GitHub Desktop.
Golang Maps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
numMap := map[string][]int{} | |
for i := 0; i <= 10; i++ { | |
numMap["numbers"] = append(numMap["numbers"], i) | |
} | |
fmt.Println(numMap) | |
for j := 10; j < 20; j++ { | |
numMap["numbers"] = append(numMap["numbers"], j) | |
} | |
fmt.Println(numMap) | |
fmt.Println("Hello, playground") | |
mapSlice := [3]map[string]string{} | |
addrInfo := map[string][]map[string]string{} | |
val := map[string]string{} | |
val = map[string]string{"fname": "go", "lname": "tool"} | |
mapSlice[0] = val | |
addrInfo["user"] = append(addrInfo["user"], val) | |
fmt.Println(addrInfo["user"]) | |
val = map[string]string{"fname": "go", "lname": "dev"} | |
mapSlice[1] = val | |
addrInfo["user"] = append(addrInfo["user"], val) | |
fmt.Println(addrInfo) | |
fmt.Println(mapSlice) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment