37 lines
504 B
Go
37 lines
504 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type contactInfo struct {
|
|
email string
|
|
zipCode int
|
|
}
|
|
|
|
type person struct {
|
|
firstName string
|
|
lastName string
|
|
contactInfo
|
|
}
|
|
|
|
func main() {
|
|
jim := person{
|
|
firstName: "Jim",
|
|
lastName: "Party",
|
|
contactInfo: contactInfo{
|
|
email: "jim@gmail.com",
|
|
zipCode: 3177,
|
|
},
|
|
}
|
|
|
|
jim.updateName("test")
|
|
jim.print()
|
|
}
|
|
|
|
func (pointerToPerson *person) updateName(name string) {
|
|
(*pointerToPerson).firstName = name
|
|
}
|
|
|
|
func (p person) print() {
|
|
fmt.Printf("%+v\n", p)
|
|
}
|