Skip to content

Instantly share code, notes, and snippets.

@enil
Created November 3, 2016 08:47
Show Gist options
  • Save enil/eec7652f9db6d185e9b6e1a9be2c52ff to your computer and use it in GitHub Desktop.
Save enil/eec7652f9db6d185e9b6e1a9be2c52ff to your computer and use it in GitHub Desktop.
Populate a Go slice using append and cap
numbers := make([]int, 0, 10)
for i := 0; i < cap(numbers); i++ {
numbers = append(numbers, i)
}
fmt.Println(numbers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment