I'm creating a map of structs to hold different information. A sample struct I am using is:
type Test struct{
Value1 string
Value2 string
Value3 string
Value4 string
}
func main() {
testMap := make(map[string]*Test) //using a pointer to map
func2(testMap)
//pass map to another function for more additions.
}
func func2 (testMap map[string]*Test) {
a, b := getVal(); //get some random values
res := concat(a,b) //basically create a string key based on values a and b
testMap[res].value1 = a //****
testMap[res].value2 = b
//do something else
testMap[res].value3 = "hello"
}
I'm basically trying to create a map and add values to it as I get them, but im getting a invalid memory address or nil pointer dereference
error on **** line (see code for ***).