golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/codeaction/imports.txt (about) 1 This test verifies the behavior of the 'source.organizeImports' code action. 2 3 -- go.mod -- 4 module mod.test/imports 5 6 go 1.18 7 8 -- add.go -- 9 package imports //@codeaction("imports", "", "source.organizeImports", add) 10 11 import ( 12 "fmt" 13 ) 14 15 func _() { 16 fmt.Println("") 17 bytes.NewBuffer(nil) //@diag("bytes", re"(undeclared|undefined)") 18 } 19 20 -- @add/add.go -- 21 package imports //@codeaction("imports", "", "source.organizeImports", add) 22 23 import ( 24 "bytes" 25 "fmt" 26 ) 27 28 func _() { 29 fmt.Println("") 30 bytes.NewBuffer(nil) //@diag("bytes", re"(undeclared|undefined)") 31 } 32 33 -- good.go -- 34 package imports //@codeactionerr("imports", "", "source.organizeImports", re"found 0 CodeActions") 35 36 import "fmt" 37 38 func _() { 39 fmt.Println("") 40 } 41 42 -- issue35458.go -- 43 44 45 46 47 48 // package doc 49 package imports //@codeaction("imports", "", "source.organizeImports", issue35458) 50 51 52 53 54 55 56 func _() { 57 println("Hello, world!") 58 } 59 60 61 62 63 64 65 66 67 -- @issue35458/issue35458.go -- 68 // package doc 69 package imports //@codeaction("imports", "", "source.organizeImports", issue35458) 70 71 72 73 74 75 76 func _() { 77 println("Hello, world!") 78 } 79 80 81 82 83 84 85 86 87 -- multi.go -- 88 package imports //@codeaction("imports", "", "source.organizeImports", multi) 89 90 import "fmt" 91 92 import "bytes" //@diag("\"bytes\"", re"not used") 93 94 func _() { 95 fmt.Println("") 96 } 97 98 -- @multi/multi.go -- 99 package imports //@codeaction("imports", "", "source.organizeImports", multi) 100 101 import "fmt" 102 103 //@diag("\"bytes\"", re"not used") 104 105 func _() { 106 fmt.Println("") 107 } 108 109 -- needs.go -- 110 package imports //@codeaction("package", "", "source.organizeImports", needs) 111 112 func goodbye() { 113 fmt.Printf("HI") //@diag("fmt", re"(undeclared|undefined)") 114 log.Printf("byeeeee") //@diag("log", re"(undeclared|undefined)") 115 } 116 117 -- @needs/needs.go -- 118 package imports //@codeaction("package", "", "source.organizeImports", needs) 119 120 import ( 121 "fmt" 122 "log" 123 ) 124 125 func goodbye() { 126 fmt.Printf("HI") //@diag("fmt", re"(undeclared|undefined)") 127 log.Printf("byeeeee") //@diag("log", re"(undeclared|undefined)") 128 } 129 130 -- remove.go -- 131 package imports //@codeaction("package", "", "source.organizeImports", remove) 132 133 import ( 134 "bytes" //@diag("\"bytes\"", re"not used") 135 "fmt" 136 ) 137 138 func _() { 139 fmt.Println("") 140 } 141 142 -- @remove/remove.go -- 143 package imports //@codeaction("package", "", "source.organizeImports", remove) 144 145 import ( 146 "fmt" 147 ) 148 149 func _() { 150 fmt.Println("") 151 } 152 153 -- removeall.go -- 154 package imports //@codeaction("package", "", "source.organizeImports", removeall) 155 156 import ( 157 "bytes" //@diag("\"bytes\"", re"not used") 158 "fmt" //@diag("\"fmt\"", re"not used") 159 160 ) 161 162 func _() { 163 } 164 165 -- @removeall/removeall.go -- 166 package imports //@codeaction("package", "", "source.organizeImports", removeall) 167 168 //@diag("\"fmt\"", re"not used") 169 170 func _() { 171 } 172 173 -- twolines.go -- 174 package imports 175 func main() {} //@codeactionerr("main", "", "source.organizeImports", re"found 0")