File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -833,13 +833,21 @@ func identEqual(expr ast.Expr, name string) bool {
833
833
//
834
834
// import "C"
835
835
//
836
+ // or the equivalent:
837
+ //
838
+ // import `C`
839
+ //
836
840
// Note that parentheses do not affect the result.
837
841
func isCgoImport (decl * ast.GenDecl ) bool {
838
842
if decl .Tok != token .IMPORT || len (decl .Specs ) != 1 {
839
843
return false
840
844
}
841
845
spec := decl .Specs [0 ].(* ast.ImportSpec )
842
- return spec .Path .Value == `"C"`
846
+ v , err := strconv .Unquote (spec .Path .Value )
847
+ if err != nil {
848
+ panic (err ) // should never error
849
+ }
850
+ return v == "C"
843
851
}
844
852
845
853
// joinStdImports ensures that all standard library imports are together and at
Original file line number Diff line number Diff line change @@ -10,18 +10,36 @@ package p
10
10
import "C"
11
11
import "os"
12
12
13
+ import `C`
14
+ import "os"
15
+
13
16
import "C"
14
17
import (
15
18
"io"
16
19
"utf8"
17
20
)
18
21
22
+ import `C`
23
+ import (
24
+ "io"
25
+ "utf8"
26
+ )
27
+
19
28
-- foo.go.golden --
20
29
package p
21
30
22
31
import "C"
23
32
import "os"
24
33
34
+ import "C"
35
+ import "os"
36
+
37
+ import "C"
38
+ import (
39
+ "io"
40
+ "utf8"
41
+ )
42
+
25
43
import "C"
26
44
import (
27
45
"io"
You can’t perform that action at this time.
0 commit comments