# Collections Of Unknown Length in Go

DevFeed: [Collections Of Unknown Length in Go](<https://devfeed.tech/articles/collections-of-unknown-length-in-go-22063.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2013/08/collections-of-unknown-length-in-go.html>)

Published: 2013-08-26T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Programming language](<https://devfeed.tech/topics/programming-language.md>), [data](<https://devfeed.tech/topics/data.md>)

Tags: [ardan-labs](<https://devfeed.tech/tags/ardan-labs.md>), [article](<https://devfeed.tech/tags/article.md>), [blog](<https://devfeed.tech/tags/blog.md>), [collections](<https://devfeed.tech/tags/collections.md>), [go](<https://devfeed.tech/tags/go.md>), [go-programming](<https://devfeed.tech/tags/go-programming.md>), [golang](<https://devfeed.tech/tags/golang.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-language](<https://devfeed.tech/tags/programming-language.md>), [slices](<https://devfeed.tech/tags/slices.md>)

## AI overview

This article explains how to use Go slices for collections whose length is unknown. It concludes that slices are generally preferable to linked lists in practical cases, while noting considerations such as shared underlying arrays and related performance edge cases.

## Source excerpt

If you are coming to Go after using a programming language like C# or Java, the first thing you will discover is that there are no traditional collection types like List and Dictionary. That really threw me off for months. I found a package called container/list and gravitated to using it for almost everything. Something in the back of my head kept nagging me. It didn't make any sense that the language designers would not directly support managing a collection of unknown length. Everyone talks about how slices are widely used in the language and here I am only using them when I have a well defined capacity or they are returned to me by some function. Something is wrong!! So I wrote an article earlier in the month that took the covers off of slices in a hope that I would find some magic that I was missing. I now know how slices work but at the end of the day, I still had an array that would have to grow. I was taught in school that linked lists were more efficient and gave you a better way to store large collections of data. Especially when the number of items you need to collect is unknown. It made sense to me. When I thought about using an empty slice, I had this very WRONG picture in my head: