package main

import (
	"fmt"
)

type User struct {
	First string
	Last  string
	Email *string
}

func main() {
	u := User{}
	u.First = "Rob"
	u.Last = "Pike"
	u.Email = new(string)
	*(u.Email) = "commander@google.com"

	fmt.Println(u.First, u.Last, *u.Email)
	reset(u)
	fmt.Println(u.First, u.Last, *u.Email)
}

// even though we pass by value, it has an underlying pointer, which we have reference to a memory space and can mutate that variable.
func reset(u User) {
	u.First = ""
	u.Last = ""
	*(u.Email) = "nobody@google.com"
}
