mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:33:04 +08:00
16 lines
287 B
Go
16 lines
287 B
Go
package main
|
|
import "fmt"
|
|
|
|
func main() {
|
|
sl_from := []int{1, 2, 3}
|
|
sl_to := make([]int, 10)
|
|
|
|
n := copy(sl_to, sl_from)
|
|
fmt.Println(sl_to)
|
|
fmt.Printf("Copied %d elements\n", n) // n == 3
|
|
|
|
sl3 := []int{1, 2, 3}
|
|
sl3 = append(sl3, 4, 5, 6)
|
|
fmt.Println(sl3)
|
|
}
|