Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
Tips and Traps¶
- Please refer to Ordered Map in Golang for discussions on ordered maps in Golang.
In [3]:
import "fmt"
In [1]:
m := map[string]int {
"how": 1,
"are": 2,
"you": 3,
}
m
Out[1]:
In [6]:
m["are"]
Out[6]:
In [3]:
val, found := m["are"]
In [4]:
val
Out[4]:
In [5]:
found
Out[5]:
Iterate a Map¶
In [10]:
ports := map[string]int {
"jupyterlab": 8888,
"jupyterhub": 8000,
"gitpod": 8000,
"vscode": 8080,
}
for prefix, port := range ports {
fmt.Printf("%s: %d\n", prefix, port)
}