Pointer to non-composite literal

go

Solution

If I understand correctly that the only point of `x` is to allocate the `int`, I recommend something even more "verbose":

y := new(int)
*y = 5

I don't see getting it any shorter than what you have. Since the `&` operator requires its operand to be either addressable or a composite literal, you're either stuck doing what you're doing to get something addressable, or you can do what I suggest and avoid the `&` altogether.

Problem

Is there an established pattern for getting pointers to non-composite literals? ``` x := 5 y := &x ``` The above code works, but is awfully verbose.

Original source