Go/Arrays
From charlesreid1
Go blog post: arrays, slices, and strings: https://blog.golang.org/slices
Arrays in Go
"Arrays are not often seen in Go programs because the size of an array is part of its type, which limits its expressive power."
The most common use of arrays are to store slices, which we will see in a moment.
Array size is a part of the type
An important characteristic of arrays is that their size is a part of their type.
The two variables defined here are of two distinct types:
var buffer [256]byte var buffer2 [512]byte
This is because the size of the array is allocated at initialization time. You can use the square bracket syntax to access elements of an array, buffer[0] through buffer[255]. The program crashes if you access an index outside of its range.
Array slices
See Go/Slices
Flags
| Go notes on Go
Go/Strings · Go/Arrays · Go/Slices
Go/Lists · Go/Maps · Go/Stacks · Go/Queues
Go/Naming Conventions · Go/Design Patterns
Go/Timing · Go/Profiling · Go/Benchmarking
Go/Tests · Go/Travis CI · Go/Makefiles
our vim + go setup uses custom solarized colors for Golang
|