August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, we are going to use a map for storing all our pointers as integers. The name of the program is mapStar.go and it contains the following Go code:
package main
import (
"runtime"
)
func main() {
var N = 40000000
myMap := make(map[int]*int)
for i := 0; i < N; i++ {
value := int(i)
myMap[value] = &value
}
runtime.GC()
_ = myMap[0]
}
The name of the map that stores the integer pointers is myMap. A for loop is used for putting the integer values into the map.
Read now
Unlock full access