Quick actions

cmd+k|ctrl+k

Navigation

Languages

Essential Go / Slices

Snippet info

Language

Go

Visibility

public

Author

kkowalczyk

Created

2019-03-26T10:09:32Z

Updated

2019-03-26T10:09:32Z

package main

import "fmt"

func main() {
	slice := make([]int, 0, 5)
	// append element to end of slice
	slice = append(slice, 5)
	// append multiple elements to end
	slice = append(slice, 3, 4)
	fmt.Printf("length of slice is: %d\n", len(slice))
	fmt.Printf("capacity of slice is: %d\n", cap(slice))
}
INFO