DRYな備忘録

Don't Repeat Yourself.

【Go言語】固定長arrayからsliceへの変換 "convert array to slice"

こうです

    arr := [4]byte{10, 20, 30, 40}
    slc := arr[:]
    fmt.Printf("%T\n%T\n", arr, slc)

参考

ここにちゃんと書いてあった

This is also the syntax to create a slice given an array:

x := [3]string{"Лайка", "Белка", "Стрелка"}
s := x[:] // a slice referencing the storage of x