Created
December 20, 2016 23:42
-
-
Save mohae/54c1b0e2cba548e61e9ad73df0d8d5e3 to your computer and use it in GitHub Desktop.
3 parm vs 2 parm slice make
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
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| b := make([]byte, 0, 4096) | |
| fmt.Printf("len: %d\t\tcap: %d\t%#v\n", len(b), cap(b), b) | |
| // make it shorter for printout reasons; | |
| b = make([]byte, 128) | |
| fmt.Printf("len: %d\tcap: %d\t%#02v\n", len(b), cap(b), b) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment