aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/build_import_comment.txt
blob: b500340bfb48b6e0405702caa67d7cb267d8bec3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Test in GOPATH mode first.
env GO111MODULE=off
cd m

# Import comment matches
go build -n works.go

# Import comment mismatch
! go build -n wrongplace.go
stderr 'wrongplace expects import "my/x"'

# Import comment syntax error
! go build -n bad.go
stderr 'cannot parse import comment'

# Import comment conflict
! go build -n conflict.go
stderr 'found import comments'


# Test in module mode.
# We ignore import comments, so these commands should succeed.
env GO111MODULE=on

# Import comment matches
go build -n works.go

# Import comment mismatch
go build -n wrongplace.go

# Import comment syntax error
go build -n bad.go

# Import comment conflict
go build -n conflict.go

-- m/go.mod --
module m

go 1.16
-- m/bad.go --
package p

import "m/bad"
-- m/conflict.go --
package p

import "m/conflict"
-- m/works.go --
package p

import _ "m/works/x"
-- m/wrongplace.go --
package p

import "m/wrongplace"
-- m/bad/bad.go --
package bad // import
-- m/conflict/a.go --
package conflict // import "a"
-- m/conflict/b.go --
package conflict /* import "b" */
-- m/works/x/x.go --
package x // import "m/works/x"
-- m/works/x/x1.go --
package x // important! not an import comment
-- m/wrongplace/x.go --
package x // import "my/x"