I'm pretty new to Go and trying to track down a bug in my codebase. In the process I've distilled the problem down to a single call to append()
, but can't figure out why it's behaving the way it is...
func main() {
foo := []string{"a", "b", "c"}
fmt.Printf("before: %v
", foo)
i := 0
noop(append(foo[:i], foo[i+1:]...)) // -- call append, but do nothing with the result
fmt.Printf(" after: %v
", foo)
}
func noop(a interface{}) {} // -- avoid "evaluated but not used" errors
So, what the heck is really going on here?