Cover page by David Chisnall

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

5. Arrays and Slices

Almost every programming language has a data structure that it calls an array, but the exact semantics vary considerably. In some languages, an array is a dynamically resizeable ordered collection of objects. In others, it’s a block of memory, with some vague hint that it probably contains variables of a specific type.

In Go, arrays are a very low-level data structure. Like C arrays, they are simply blocks of memory, but there are some important differences. Remember that Go does not permit pointer arithmetic. In C, array subscripting is just another way of writing pointer arithmetic, and you can use array and pointer types almost interchangeably.

In Go, pointers and arrays are distinct types. Because arrays and pointers ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required