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