package main
import
"fmt"
func main() {
slice := []int{10, 20, 30, 40}
// Get length of slice with len.
length := len(slice)
fmt.Println(slice)
fmt.Println(length)
// Append an element, and take the length again.
slice = append(slice, 50)
fmt.Println(slice)
fmt.Println(len(slice))
}
[10 20 30 40]
4
[10 20 30 40 50]
5