Go Struct

In Go, Struct can be used to create user-defined types.

Struct is a composite type means it can have different properties and each property can have their own type and value.

Struct can represent real-world entity with these properties. We can access a property data as a single entity. It is also valued types and can be constructed with the new() function.

Go Struct Example


{John Anderson 30}

Go Embedded Struct

Struct is a data type and can be used as an anonymous field (having only the type). One struct can be inserted or "embedded" into other struct.

It is a simple 'inheritance' which can be used to implement implementations from other type or types.

Go Embedded Struct Example


{Raj Kumar}   I am a person
{{John Ponting} 11}  I am a employee

Next TopicGo Interface

Hot Tutorials

Contact US


Go Struct