github.com/v2fly/tools@v0.100.0/internal/lsp/testdata/statements/append.go (about) 1 package statements 2 3 func _() { 4 type mySlice []int 5 6 var ( 7 abc []int //@item(stmtABC, "abc", "[]int", "var") 8 abcdef mySlice //@item(stmtABCDEF, "abcdef", "mySlice", "var") 9 ) 10 11 /* abcdef = append(abcdef, ) */ //@item(stmtABCDEFAssignAppend, "abcdef = append(abcdef, )", "", "func") 12 13 // don't offer "abc = append(abc, )" because "abc" isn't necessarily 14 // better than "abcdef". 15 abc //@complete(" //", stmtABC, stmtABCDEF) 16 17 abcdef //@complete(" //", stmtABCDEF, stmtABCDEFAssignAppend) 18 19 /* append(abc, ) */ //@item(stmtABCAppend, "append(abc, )", "", "func") 20 21 abc = app //@snippet(" //", stmtABCAppend, "append(abc, ${1:})", "append(abc, ${1:})") 22 } 23 24 func _() { 25 var s struct{ xyz []int } 26 27 /* xyz = append(s.xyz, ) */ //@item(stmtXYZAppend, "xyz = append(s.xyz, )", "", "func") 28 29 s.x //@snippet(" //", stmtXYZAppend, "xyz = append(s.xyz, ${1:})", "xyz = append(s.xyz, ${1:})") 30 31 /* s.xyz = append(s.xyz, ) */ //@item(stmtDeepXYZAppend, "s.xyz = append(s.xyz, )", "", "func") 32 33 sx //@snippet(" //", stmtDeepXYZAppend, "s.xyz = append(s.xyz, ${1:})", "s.xyz = append(s.xyz, ${1:})") 34 } 35 36 func _() { 37 var foo [][]int 38 39 /* append(foo[0], ) */ //@item(stmtFooAppend, "append(foo[0], )", "", "func") 40 41 foo[0] = app //@complete(" //"),snippet(" //", stmtFooAppend, "append(foo[0], ${1:})", "append(foo[0], ${1:})") 42 }