2 ways to delete an element from a slice
yourbasic.org/golang
Fast version (changes order)
a := []string{"A", "B", "C", "D", "E"}
i := 2
The code copies a single element and runs in constant time.
Slow version (maintains order)
a := []string{"A", "B", "C", "D", "E"}
i := 2
The code copies len(a) - i - 1 elements and runs in linear time.
转载于:https://www.cnblogs.com/oxspirt/p/11273308.html