Go code
type Person struct { Name string }
person := Person{Name: "Maya"}
fmt.Println(person.Name)Line-by-line explanation
- A Person type is declared.
- The literal creates one Person.
- Name receives Maya.
- Dot notation reads the field.
Expected output
MayaThis is the expected result.