mirror of
https://github.com/bootdotdev/fcc-learn-golang-assets.git
synced 2025-12-11 07:41:18 +00:00
50 lines
998 B
Go
50 lines
998 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")
|
|
|
|
}
|