Debian Codegraph @

testdata/script/std-imports.txtar

raw
1 exec gofumpt -w foo.go
2 cmp foo.go foo.go.golden
3
4 exec gofumpt -d foo.go.golden
5 ! stdout .
6
7 -- go.mod --
8 module nodomainmod/mod1
9
10 go 1.16
11 -- foo.go --
12 package p
13
14 import (
15 "io"
16 "io/ioutil" // if the user keeps them in the top group, obey that
17 _ "io/ioutil"
18
19 _ "image/png"
20
21 "bufio" // the above is for a side effect; this one has a comment
22 )
23
24 import (
25 "os"
26
27 "foo.local/one"
28
29 bytes_ "bytes"
30
31 "io"
32 )
33
34 import (
35 "foo.local/two"
36
37 "fmt"
38 )
39
40 // If they are in order, but with extra newlines, join them.
41 import (
42 "more"
43
44 "std"
45 )
46
47 // We need to split std vs non-std in this case too.
48 import (
49 "foo.local"
50 "foo.local/three"
51 math "math"
52 )
53
54 import (
55 "x"
56 // don't mess up this comment
57 "y"
58 // or many
59 // of them
60 "z"
61 )
62
63 // This used to crash gofumpt, as there's no space to insert an extra newline.
64 import (
65 "std"
66 "non.std/pkg"
67 )
68
69 // All of the extra imports below are known to not belong in std.
70 // For example/ and test/, see https://golang.org/issue/37641.
71 import (
72 "io"
73
74 "example/foo"
75 "internal/bar"
76 "test/baz"
77 )
78
79 import (
80 "io"
81
82 "nodomainmod"
83 "nodomainmod/mod1/pkg1"
84 "nodomainmod/mod2"
85 "nodomainmodextra"
86 )
87
88 import (
89 "io"
90
91 "nodomainother/mod.withdot/pkg1"
92 )
93
94 // TODO: fix issue 225.
95 import (
96 "path/filepath"
97 "time"
98 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1"
99 "k8s.io/apimachinery/pkg/types"
100 "sigs.k8s.io/yaml"
101 )
102 -- foo.go.golden --
103 package p
104
105 import (
106 "io"
107 "io/ioutil" // if the user keeps them in the top group, obey that
108 _ "io/ioutil"
109
110 _ "image/png"
111
112 "bufio" // the above is for a side effect; this one has a comment
113 )
114
115 import (
116 "io"
117 "os"
118
119 "foo.local/one"
120
121 bytes_ "bytes"
122 )
123
124 import (
125 "fmt"
126
127 "foo.local/two"
128 )
129
130 // If they are in order, but with extra newlines, join them.
131 import (
132 "more"
133 "std"
134 )
135
136 // We need to split std vs non-std in this case too.
137 import (
138 math "math"
139
140 "foo.local"
141 "foo.local/three"
142 )
143
144 import (
145 "x"
146 // don't mess up this comment
147 "y"
148 // or many
149 // of them
150 "z"
151 )
152
153 // This used to crash gofumpt, as there's no space to insert an extra newline.
154 import (
155 "std"
156
157 "non.std/pkg"
158 )
159
160 // All of the extra imports below are known to not belong in std.
161 // For example/ and test/, see https://golang.org/issue/37641.
162 import (
163 "io"
164
165 "example/foo"
166 "internal/bar"
167 "test/baz"
168 )
169
170 import (
171 "io"
172 "nodomainmodextra"
173
174 "nodomainmod"
175 "nodomainmod/mod1/pkg1"
176 "nodomainmod/mod2"
177 )
178
179 import (
180 "io"
181 "nodomainother/mod.withdot/pkg1"
182 )
183
184 // TODO: fix issue 225.
185 import (
186 "path/filepath"
187 "time"
188
189 "github.com/tinkerbell/tink/pkg/apis/core/v1alpha1"
190 "k8s.io/apimachinery/pkg/types"
191
192 "sigs.k8s.io/yaml"
193 )