Can I create a pointer to expression result without making new variable in Go?
package test
func foo(*uint32) {
}
func main() {
foo(&(uint32(time.Now().Unix()))) //this line gives me error
//cannot take the address of uint32(...
}
In the question comments, OP says that the pointers are needed for a protobuf message.
The proto package provides helper functions for creating pointers to integers and other values.
Use the proto.Uint32 function to get a pointer to a uint32.
x.Time = proto.Uint32(u)