Agreed, append with only one argument doesn't look good and should be vetted.
As a superset of this problem, any use of *a* = append(*b*, *c*) with *b* != *a* (i.e. not assigning back to the same slice variable) looks either broken or cryptic me. This holds whether *c* is zero or one or more variadic elements. I mean, while there are a few usages where it is written on purpose, it makes reading and reasoning much more difficult. Val On Wednesday, August 16, 2017 at 4:53:16 AM UTC+2, DrGo wrote: > > Hello, > > The following compiles as well as evades scrutiny by go Vet (and many a > human reviewer) resulting in perplexing bugs. What purpose calling append() > with only one argument serves? Shouldn't it be banned? > > > ``` > var byteArray= []byte{'A', 'B',} > > func main() { > buf:=[]byte {'C'} > buf = append(byteArray) //<--- gotche meant: buf = append(*buf*, > byteArray) > fmt.Println(string(buf)) > } > ``` > https://play.golang.org/p/jP8NGiEN9A > > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.