October 2015
Beginner to intermediate
400 pages
14h 44m
English
A struct is an aggregate data type that groups together zero or more named values of arbitrary types as a single entity. Each value is called a field. The classic example of a struct from data processing is the employee record, whose fields are a unique ID, the employee’s name, address, date of birth, position, salary, manager, and the like. All of these fields are collected into a single entity that can be copied as a unit, passed to functions and returned by them, stored in arrays, and so on.
These two statements declare a struct type called Employee
and a variable called dilbert that is an instance
of an Employee:
type Employee struct { ID int Name string Address string DoB time.Time Position string Salary int ManagerID ...