The error occurs because you are trying to take the address of a value that is not addressable, such as a literal, a function return value, or a map index result. You must assign the value to a variable first, then take the address of that variable.
// Incorrect: cannot take address of literal or function result
// ptr := &MyStruct{Field: 10}
// ptr := &getStruct()
// Correct: assign to a variable first
val := MyStruct{Field: 10}
ptr := &val
// Or if calling a function
val = getStruct()
ptr = &val