github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/cmd/gofmt/testdata/import.input (about) 1 // package comment 2 package main 3 4 import ( 5 "fmt" 6 "math" 7 "log" 8 "errors" 9 "io" 10 ) 11 12 import ( 13 "fmt" 14 15 "math" 16 17 "log" 18 19 "errors" 20 21 "io" 22 ) 23 24 // We reset the line numbering to test that 25 // the formatting works independent of line directives 26 //line :19 27 28 import ( 29 "fmt" 30 "math" 31 "log" 32 "errors" 33 "io" 34 35 "fmt" 36 37 "math" 38 39 "log" 40 41 "errors" 42 43 "io" 44 ) 45 46 import ( 47 // a block with comments 48 "fmt" // for Printf 49 "math" 50 "log" // for Fatal 51 "errors" 52 "io" // for Reader 53 ) 54 55 import ( 56 "fmt" // for Printf 57 58 "math" 59 60 "log" // for Fatal 61 62 "errors" 63 64 "io" // for Reader 65 ) 66 67 import ( 68 // for Printf 69 "fmt" 70 71 "math" 72 73 // for Fatal 74 "log" 75 76 "errors" 77 78 // for Reader 79 "io" 80 ) 81 82 import ( 83 "fmt" // for Printf 84 "math" 85 "log" // for Fatal 86 "errors" 87 "io" // for Reader 88 89 "fmt" // for Printf 90 91 "math" 92 93 "log" // for Fatal 94 95 "errors" 96 97 "io" // for Reader 98 ) 99 100 import ( 101 "fmt" // for Printf 102 103 "math" 104 "log" // for Fatal 105 "errors" 106 "io" // for Reader 107 108 "fmt" // for Printf 109 "math" 110 "log" // for Fatal 111 "errors" 112 "io" // for Reader 113 ) 114 115 // Test deduping and extended sorting 116 import ( 117 "B" // B 118 a "A" // aA 119 b "A" // bA2 120 b "A" // bA1 121 . "B" // .B 122 . "B" 123 "C" 124 "C" 125 "C" 126 a "D" // aD 127 "B" 128 _ "B" // _b 129 ) 130 131 import ( 132 "dedup_by_group" 133 "dedup_by_group" 134 135 "dedup_by_group" 136 ) 137 138 import ( 139 /* comment */ io1 "io" 140 "fmt" // for Printf 141 /* comment */ "log" 142 /* comment */ io2 "io" 143 ) 144 145 import ( 146 /* comment */ io2 "io" // hello 147 /* comment */ io1 "io" 148 "math" /* right side */ 149 "fmt" 150 // end 151 ) 152 153 import ( 154 /* comment */ io1 "io" /* before */ // after 155 "fmt" 156 "errors" // for New 157 io2 "io" // another 158 // end 159 ) 160 161 import ( 162 /* left */ "fmt" /* right */ 163 "errors" // for New 164 /* left */ "math" /* right */ 165 "log" // for Fatal 166 ) 167 168 import /* why */ /* comment here? */ ( 169 /* comment */ "fmt" 170 "math" 171 ) 172 173 // Reset it again 174 //line :100 175 176 // Dedup with different import styles 177 import ( 178 "path" 179 . "path" 180 _ "path" 181 "path" 182 pathpkg "path" 183 ) 184 185 /* comment */ 186 import ( 187 "math" // for Abs 188 "fmt" 189 // This is a new run 190 "errors" 191 "fmt" 192 "errors" 193 ) 194 195 // End an import declaration in the same line 196 // as the last import. See golang.org/issue/33538. 197 // Note: Must be the last (or 2nd last) line of the file. 198 import("fmt" 199 "math")