for
loop instead of append
SCC-S101125
26func imageCopyB(src []image.Image) (dst []image.Image) {
27 dst = make([]image.Image, 0, len(src))
28 for _, img := range src {29 dst = append(dst, img)
30 }
31 return dst
There is no need to range
over the slice and append elements one by one;
instead, use append
because it's clear, simple, and idiomatic.
a := []int{1, 2}
b := []int{3, 4}
for _, v := range a {
b = append(b, v)
}
a := []int{1, 2}
b := []int{3, 4}
b = append(b, a...)