Overview of Go Type System
Built-in string type:
Built-in boolean type:
Built-in numeric types:
byte is a built-in alias of
rune is a built-in alias of
int32. We can also declare custom type aliases (see below).
pointer types - C pointer alike.
struct types - C struct alike.
function types - functions are first-class types in Go.
- array types - fixed-length container types.
- slice type - dynamic-length and dynamic-capacity container types.
- map types - maps are associative arrays (or dictionaries). The standard Go compiler implements maps as hashtables.
channel types - channels are used to synchronize data among goroutines (the green threads in Go).
interface types - interfaces play a key role in reflection and polymorphism.
// Assume T is an arbitrary type and Tkey is
// Define a solo new type.
A defined type is a type defined in a type definition.
All basic types are defined. A non-defined type must be a composite type.
In the following example. type alias C and type literal string both represent the same non-defined types, but type A and type alias B both represent the same defined type.
type A string