Implement package-global maps (of max 8 entries)

This commit is contained in:
Ayke van Laethem
2018-08-24 00:56:20 +02:00
parent 2b78b6d7e8
commit 179cf74b01
4 changed files with 139 additions and 5 deletions
+4
View File
@@ -14,6 +14,8 @@ type Stringer interface {
const SIX = 6
var testmap = map[string]int{"data": 3}
func main() {
println("Hello world from Go!")
println("The answer is:", calculateAnswer())
@@ -25,6 +27,7 @@ func main() {
m := map[string]int{"answer": 42, "foo": 3}
readMap(m, "answer")
readMap(testmap, "data")
foo := []int{1, 2, 4, 5}
println("len/cap foo:", len(foo), cap(foo))
@@ -50,6 +53,7 @@ func runFunc(f func(int), arg int) {
}
func readMap(m map[string]int, key string) {
println("map length:", len(m))
println("map read:", key, "=", m[key])
}