How to Create a Pointer to a Literal Value in Go

Assign the literal to a variable first, then use the address-of operator (&) to create a pointer to that variable.

Use the & operator to take the address of a literal value and assign it to a typed pointer variable.

s := "hello"
p := &s

Note: You cannot take the address of a literal directly (e.g., &"hello" is invalid) because literals are not addressable. You must first assign the literal to a variable.