Video:

Arrays Vs Slices in Go

April 2, 2021

Course Instructor: Elliot Forbes

Hey Gophers! My name is Elliot and I'm the creator of TutorialEdge and I've been working with Go systems for roughly 5 years now. Feel free to reach out to me on twitter - @Elliot_F

👋 Hey Gophers, in this video, we are going to take a quick look at the main differences between an Array in Go and a Slice in Go.

Arrays vs Slices in Go

The main difference between an Array object in Go and a Slice object is that the Slice is effectively an abstraction built on-top of the Array. They give us programmers a greater degree of flexibility when it comes to working with this particular data structure as they handle things like the automatic resizing of arrays whenever we hit a limit.

In most situations, you are not likely going to want to specify an exact length of an array so it’s likely that you’l end up just resorting to Slices for the majority of your use cases.