Skip to content

Instantly share code, notes, and snippets.

@linfongi
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linfongi/c9a56fface703f842acf to your computer and use it in GitHub Desktop.
Save linfongi/c9a56fface703f842acf to your computer and use it in GitHub Desktop.

Go's arrays are values. An array variable denotes the entire array; it is not a pointer to the first array element (as would be the case in C). This means that when you assign or pass around an array value you will make a copy of its contents. (To avoid the copy you could pass a pointer to the array, but then that's a pointer to an array, not an array.) One way to think about arrays is as a sort of struct but with indexed rather than named fields: a fixed-size composite value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment