Structs
Table of Contents
Basics of struct tutorial
type Developer struct {
Name string
Age int
}
// By default, fields are initialized with zero values of their own types.
var devloper Developer
developer.Name = "Yeongho Kim"
developer.Age = 32
The dot notation works seamlessly with a pointer to a struct
- Field order is significant to type identity.
- Fields are exported if the field's name begins with a capital letter.
- A
structnamedScannot have a filed of typeSitself, but it can have its pointer,*S. - The empty
struct{}'s size is zero.
struct literal
- Fields with no initial value will be initialized with its zero value.
Comparing Structs