go-tools
go-tools copied to clipboard
quickfix: report usage of ellipsis usage when appending a short list to a slice
Please consider the following code
slice := []int{1, 2, 3}
// Appending slices
slice := append(slice, []int{4, 5, 6}...)
I would expect to report that this would be simpler
slice := []int{1, 2, 3}
// Appending to a slice
slice := append(slice, 4, 5, 6)
I noticed here today, but I already faced in my own code
https://github.com/xhd2015/xgo/pull/163#discussion_r1627672652
Some other examples can be found via GitHub
https://github.com/search?q=lang%3Ago+append+%22...%22+%22%5B%5Dstring%22&type=code
Here is one, the file is using this pattern
https://github.com/johnmanjiro13/gh-bump/blob/fe3931d1142abe7632a50905a9f808579b250d20/gh.go#L45