A struct is a collection of fields.
(And a type declaration does what you'd expect.)
Struct Fields
Struct fields are accessed using a dot.
Pointers to structs
Struct fields can be accessed through a struct pointer.
The indirection through the pointer is transparent.
Struct Literals
A struct literal denotes a newly allocated struct value by listing the values of its fields.
You can list just a subset of fields by using the Name: syntax. (And the order of named fields is irrelevant.)
The special prefix & returns a pointer to the struct value.
Do comment, if it worked/Not worked for you.
No comments:
Post a Comment