October 2016
Beginner
348 pages
6h 31m
English
In Go, it is possible to bind a type to an identifier to create a new named type that can be referenced and used wherever the type is needed. Declaring a type takes the general format as follows:
type <name identifier> <underlying type name>
The type declaration starts with the keyword type followed by a name identifier and the name of an existing underlying type. The underlying type can be a built-in named type such as one of the numeric types, a Boolean, or a string type as shown in the following snippet of type declarations:
type truth bool type quart float64 type gallon float64 type node string
A type declaration can also use a composite type literal as its underlying type. Composite types include array, slice, map, and struct. ...
Read now
Unlock full access