Created
November 3, 2016 08:47
-
-
Save enil/eec7652f9db6d185e9b6e1a9be2c52ff to your computer and use it in GitHub Desktop.
Populate a Go slice using append and cap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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