golang 在for range一个slice时,会读出其cap长度.在for的过程中,即使动态append该slice,最终for也会在第一次读取的cap长度处停止. package main import ( "fmt" ) func main() { s := make([]) s[]="a" s[]="b" s[]="c" for _,i := range s { s = append(s, s[]) fmt.Pri…
1) Append a slice b to an existing slice a: a = append(a, b...) 2) Copy a slice a to a new slice b: b = make([]T, len(a)) copy(b, a) 3) Delete item at index i: a = append(a[:i], a[i+1:]...) 4) Cut from index i till j out of slice a: a = append(a[:i],…