Skip to content

Instantly share code, notes, and snippets.

@Zhang-Siyang
Last active March 4, 2020 10:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zhang-Siyang/e701966d4d12022816c1750d7afa861c to your computer and use it in GitHub Desktop.
Save Zhang-Siyang/e701966d4d12022816c1750d7afa861c to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func test(a []int) {
a = append(a, 4)
}
func main() {
s := make([]int, 3, 4)
s[0] = 1
s[1] = 2
s[2] = 3
fmt.Println(s) //[1 2 3]
test(s)
s = s[:4]
fmt.Println(s) //[1 2 3 4]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment