Complete the code to create a struct value with default zero values.
type Person struct {
Name string
Age int
}
func main() {
p := [1]{}
fmt.Println(p)
}To create a struct value, use the struct type name followed by curly braces.
Complete the code to create a struct value with field values.
type Person struct {
Name string
Age int
}
func main() {
p := Person{
Name: [1],
Age: 30,
}
fmt.Println(p)
}String values must be enclosed in double quotes in Go.
Fix the error in creating a struct value with field names.
type Person struct {
Name string
Age int
}
func main() {
p := Person{
[1]: "Bob",
Age: 25,
}
fmt.Println(p)
}Field names are case-sensitive and must match exactly as declared in the struct.
Fill both blanks to create a struct value with fields and print the Name.
type Person struct {
Name string
Age int
}
func main() {
p := Person{
[1]: "Carol",
[2]: 40,
}
fmt.Println(p.Name)
}Use exact field names with correct capitalization to assign values.
Fill all three blanks to create a struct value, update Age, and print the updated struct.
type Person struct {
Name string
Age int
}
func main() {
p := Person{
[1]: "Dave",
[2]: 28,
}
p.[3] = 29
fmt.Println(p)
}Assign values using exact field names and update the Age field before printing.
