24 lines
297 B
Go
24 lines
297 B
Go
![]() |
package main
|
||
|
|
||
|
import "fmt"
|
||
|
|
||
|
func printSlice(s []int) {
|
||
|
fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
|
||
|
}
|
||
|
func main() {
|
||
|
var s []int
|
||
|
printSlice(s)
|
||
|
|
||
|
s = append(s, 0)
|
||
|
printSlice(s)
|
||
|
|
||
|
s = append(s, 1)
|
||
|
printSlice(s)
|
||
|
|
||
|
s = append(s, 2, 3, 4)
|
||
|
printSlice(s)
|
||
|
|
||
|
s = append(s, 56)
|
||
|
printSlice(s)
|
||
|
}
|