Local variables

The first solution often used is to declare local variables in order to derive pointers, ex. (Go playground):

  1. func main() {
  2. // Declare "host" and "port" in order to create pointers to satisfy the
  3. // fields in the "request" struct.
  4. host, port := "local", 80
  5. print(request{
  6. host: &host,
  7. port: &port,
  8. })
  9. }

This leads to cluttered, hard-to-read code where the only purpose variables serve is for deriving pointers.


Next: Typed, helper functions