July 2019
Intermediate to advanced
458 pages
12h 12m
English
A package can define its own types by using the type defined definition expression, where definition is a type that shares a defined memory representation. Custom types can be defined by basic types:
type Message string // custom stringtype Counter int // custom integertype Number float32 // custom floattype Success bool // custom boolean
They can also be defined by composite types like slices, maps, or pointers:
type StringDuo [2]string // custom array type News chan string // custom channeltype Score map[string]int // custom maptype IntPtr *int // custom pointertype Transform func(string) string // custom functiontype Result struct { // custom struct A, B int}
They can also be used in combination with other custom ...
Read now
Unlock full access