I have a struct which stores pointers like this
type Req struct {
Name *string
Address *string
Number string
}
I'm trying to create a variable with this struct type and assign values as follows
req := Req{
Name = &"Alice"
Address = &"ABCDEF"
Number = "123456"}
When I do this, I get the following error
invalid operation: cannot take address of "Alice" (untyped string constant)
invalid operation: cannot take address of "ABCDEF" (untyped string constant)
I'm not really clear on why this error is coming up and why "Alice" and "ABCDEF" are untyped string constants. I know I can assign the values to new vars and use the vars pointers in the req
struct I'm using. But I'm trying to understand why my current approach is wrong. How can I make it work?