Re:New in Go 1.20: wrapping multiple errors
by sqlcommando on Tuesday December 13, 2022 @11:33PM
(#33980027)
I don't understand what you mean by this.
[~] $ cat main.go
package main
import "fmt"
func main() {
x := []int{1, 2}
append(x, 3)
fmt.Println(x)
}
[~] $ go run main.go
# command-line-arguments
./main.go:7:2: append(x, 3) (value of type []int) is not used
and if you assign the result of the append to something else, x is unchanged.
Just a trivial example: trying to use append(x, y) without re-assigning to x? Congrats, it will compile without warnings, work fine for a while, then at one point append will reallocate and bang, have fun letting the newbie debug that on a Friday evening.