Complete the code to define a method for the struct.
func (p *Person) [1]() string { return p.name }
The method name should be GetName to define a method that returns the name.
Complete the code to call the method on the struct instance.
p := Person{name: "Alice"}
fmt.Println(p.[1]())To call the method that returns the name, use GetName.
Fix the error in the method receiver to allow modifying the struct.
func (p [1] Person) SetName(newName string) {
p.name = newName
}Using a pointer receiver *Person allows the method to modify the original struct.
Fill both blanks to create a method that returns the full name.
func (p [1] Person) FullName() string { return p.firstName + [2] + p.lastName }
The pointer receiver *Person allows access to the struct, and + concatenates strings.
Fill all three blanks to define and call a method that updates and returns the age.
func (p [1] Person) SetAge(newAge int) { p.age = newAge } func (p Person) GetAge() int { return p.[2] } p := Person{} p.[3](30) fmt.Println(p.GetAge())
Use a pointer receiver *Person in SetAge to modify the struct. The field age is returned by GetAge. Call SetAge to update the age.