Pls see code sample below (with compile error)
Question:
How come i can take the address of a struct variable (see A), but not take the address of the value return by a constructor (see B),
[Edit] see C & D - which takes the addr of a struct literal and compile without error
package main
import "fmt"
type A struct { a int }
func NewA(a int) A { return A{a: a} }
func main() {
a := NewA(10)
aa_1 := &a // A. Compiles ok
// compile error: invalid operation: cannot take address of NewA(20) (value of type A)
aa_2 := &(NewA(20)) // B. why doesn't this work ?
aa_3 := &(struct{ int }{100}). // C. compiles ok
aa_4 := &(A{100}) // D. compiles ok
fmt.Println(aa_1, aa_2, aa_3, aa_4)
}