Find the Length of an Array
You can find the length of an array - or to be correct a slice or map - in Go by using the stdlib function len(). We’ve shown some examples below to create both a slice and a map then get the length of it. In Golang, the method is the same for both. Length of Slice We define the entire slice in one go, but you can also use append() to add to the slice.