1 # Test in GOPATH mode first.
2 env GO111MODULE=off
3 cd m
4
5 # Import comment matches
6 go build -n works.go
7
8 # Import comment mismatch
9 ! go build -n wrongplace.go
10 stderr 'wrongplace expects import "my/x"'
11
12 # Import comment syntax error
13 ! go build -n bad.go
14 stderr 'cannot parse import comment'
15
16 # Import comment conflict
17 ! go build -n conflict.go
18 stderr 'found import comments'
19
20
21 # Test in module mode.
22 # We ignore import comments, so these commands should succeed.
23 env GO111MODULE=on
24
25 # Import comment matches
26 go build -n works.go
27
28 # Import comment mismatch
29 go build -n wrongplace.go
30
31 # Import comment syntax error
32 go build -n bad.go
33
34 # Import comment conflict
35 go build -n conflict.go
36
37 -- m/go.mod --
38 module m
39
40 go 1.16
41 -- m/bad.go --
42 package p
43
44 import "m/bad"
45 -- m/conflict.go --
46 package p
47
48 import "m/conflict"
49 -- m/works.go --
50 package p
51
52 import _ "m/works/x"
53 -- m/wrongplace.go --
54 package p
55
56 import "m/wrongplace"
57 -- m/bad/bad.go --
58 package bad // import
59 -- m/conflict/a.go --
60 package conflict // import "a"
61 -- m/conflict/b.go --
62 package conflict /* import "b" */
63 -- m/works/x/x.go --
64 package x // import "m/works/x"
65 -- m/works/x/x1.go --
66 package x // important! not an import comment
67 -- m/wrongplace/x.go --
68 package x // import "my/x"
69
View as plain text