struct: structure
@ 1 used to customize the complex data structures // 2. struct which may comprise a plurality of fields (attributes) // 3. The method defined struct types can be distinguished, attention and functions // 4. struct type is a value type // 5. The type can be nested struct // 6. The Go language is not the type of class, only type struct
The definition of the struct
struct declaration: type identifier struct { field1 type Field2 type } // Example: type Student struct { the Name String Age int Score int }
struct defined three forms:
. 1 . Var STU Student 2 . Var STU * = Student new new (Student) 3 . Var STU * = Student & Student {} . 1 ) where 2 and 3 return is a pointer pointing to the structure, access to the following form: // Standard form: (* STU) .Name ( * STU) .Age // shorthand: stu.Name stu.Age