Files
bootdotdev-fcc-learn-golang…/course/11-pointers/exercises/6-pointer_receiver_code/code.go
wagslane 9be3074de6 first
2023-05-01 15:25:27 -06:00

50 lines
997 B
Go

package main
import (
"fmt"
)
func (e email) setMessage(newMessage string) {
e.message = newMessage
}
// don't edit below this line
type email struct {
message string
fromAddress string
toAddress string
}
func test(e *email, newMessage string) {
fmt.Println("-- before --")
e.print()
fmt.Println("-- end before --")
e.setMessage("this is my second draft")
fmt.Println("-- after --")
e.print()
fmt.Println("-- end after --")
fmt.Println("==========================")
}
func (e email) print() {
fmt.Println("message:", e.message)
fmt.Println("fromAddress:", e.fromAddress)
fmt.Println("toAddress:", e.toAddress)
}
func main() {
test(&email{
message: "this is my first draft",
fromAddress: "sandra@mailio-test.com",
toAddress: "bullock@mailio-test.com",
}, "this is my second draft")
test(&email{
message: "this is my third draft",
fromAddress: "sandra@mailio-test.com",
toAddress: "bullock@mailio-test.com",
}, "this is my fourth draft")
}