36 lines
502 B
Go
36 lines
502 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
type contactInfo struct {
|
|
email string
|
|
zipCode int
|
|
}
|
|
|
|
type person struct {
|
|
firstName string
|
|
lastName string
|
|
contactInfo
|
|
}
|
|
|
|
func main() {
|
|
person1 := person{
|
|
firstName: "Bert",
|
|
lastName: "Bertrandt",
|
|
contactInfo: contactInfo{
|
|
email: "asd@bsd.de",
|
|
zipCode: 1234,
|
|
},
|
|
}
|
|
person1.updateName("asd")
|
|
person1.print()
|
|
}
|
|
|
|
func (p *person) updateName(newFirstName string) {
|
|
(*p).firstName = newFirstName
|
|
}
|
|
|
|
func (p person) print() {
|
|
fmt.Printf("%+v", p)
|
|
}
|