So in this answerhere, it's stated that one cannot embed a map into a struct in go. However, I was fiddling around with it, and came up with this and it does actually work, and is pretty straight forward.
package main
import (
"fmt"
"runtime"
)
type record struct {
m map[string]int
}
func main() {
practice := record{m:make(map[string]int)}
practice.m["foo"] = 2
fmt.Println(practice.m)
runtime.GC()
}
this prints map[foo:2]
However, my question is that, are there any negative sides to using this implementation of maps in structs, or are is there more efficient ways to do this?