Go — Arrays (basics)

In GO an array is a sequence of elements defined by a specific length. This is unlike other high-level programming languages like JavaScript, Python, and many more.

In GO arrays are always the same length, as they are defined. Here is an example of a initialization of an array of length 5 containing all zeroes, in GO:

We can then access or set new values for each of the “spots” in the array:

The previously mentioned length of an array can also be found by the function: “len”:

When initializing a new array, we can also put in the values we want on each place in the array, called initalization and declaration:

More often that not you will usually see “slices” in GO, than arrays.
For Slices see my next article, which will describe the differences between arrays and slices in GO.

--

--

--

Fullstack developer living in Denmark. Experience with both Web- and App development.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Install aws-cli and azcli in docker using apline linux

Which Framework to Choose: Comparing Django vs Ruby on Rails

Google App Engine Deployment Best Practices

App Architectures: SOA vs Microservices

Getting started with SugarCRM REST API using UltraStudio

Dây curoa Alpha Power Japan PU-T10–2360X25

Under-using AWS Kinesis Stream to limit AWS Lambda throughput

LUNI — Meme/utility token released on Terra jaringan network

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Nikolaj Johannes Skole Jensen

Nikolaj Johannes Skole Jensen

Fullstack developer living in Denmark. Experience with both Web- and App development.

More from Medium

Functions in GO

Let’s GO! Part 7: Aggregate Types 1: Structs

Go Tutorial Series EP.1: Building REST API with Gin

Getting started with Go — Switch Statements