Debian Codegraph @

go/analysis/passes/modernize/testdata/src/slicesdelete/slicesdelete.go

raw
1 package slicesdelete
2
3 var g struct{ f []int }
4
5 func h() []int { return []int{} }
6
7 var ch chan []int
8
9 func slicesdelete(test, other []byte, i int) {
10 const k = 1
11 _ = append(test[:i], test[i+1:]...) // want "Replace append with slices.Delete"
12
13 _ = append(test[:i+1], test[i+2:]...) // want "Replace append with slices.Delete"
14
15 _ = append(test[:i+1], test[i+1:]...) // not deleting any slice elements
16
17 _ = append(test[:i], test[i-1:]...) // not deleting any slice elements
18
19 _ = append(test[:i-1], test[i:]...) // want "Replace append with slices.Delete"
20
21 _ = append(test[:i-2], test[i+1:]...) // want "Replace append with slices.Delete"
22
23 _ = append(test[:i-2], other[i+1:]...) // different slices "test" and "other"
24
25 _ = append(test[:i-2], other[i+1+k:]...) // cannot verify a < b
26
27 _ = append(test[:i-2], test[11:]...) // cannot verify a < b
28
29 _ = append(test[:1], test[3:]...) // want "Replace append with slices.Delete"
30
31 _ = append(g.f[:i], g.f[i+k:]...) // want "Replace append with slices.Delete"
32
33 _ = append(h()[:i], h()[i+1:]...) // potentially has side effects
34
35 _ = append((<-ch)[:i], (<-ch)[i+1:]...) // has side effects
36
37 _ = append(test[:3], test[i+1:]...) // cannot verify a < b
38
39 _ = append(test[:i-4], test[i-1:]...) // want "Replace append with slices.Delete"
40
41 _ = append(test[:1+2], test[3+4:]...) // want "Replace append with slices.Delete"
42
43 _ = append(test[:1+2], test[i-1:]...) // cannot verify a < b
44 }
45
46 func issue73663(test, other []byte, i int32) {
47 const k = 1
48 _ = append(test[:i], test[i+1:]...) // want "Replace append with slices.Delete"
49
50 _ = append(test[:i-1], test[i:]...) // want "Replace append with slices.Delete"
51
52 _ = append(g.f[:i], g.f[i+k:]...) // want "Replace append with slices.Delete"
53
54 type int string // int is shadowed, so no offered fix.
55 _ = append(test[:i], test[i+1:]...)
56 }