What is a struct in Go?

Answer

A struct is Go's primary way to group related data together into a composite type. Declare one with type Person struct { Name string; Age int } and instantiate it with p := Person{Name: "Alice", Age: 30}. Structs can have methods attached to them, making them the closest Go equivalent to classes. Unlike class-based OOP, Go uses struct embedding for composition rather than inheritance. Struct fields are exported (accessible outside the package) if they start with an uppercase letter.