...
1cp go.mod go.mod.orig
2
3
4# 'go get' should fail, without updating go.mod, if the transitive dependencies
5# of the requested package (by default, the package in the current directory)
6# cannot be resolved.
7
8! go get
9stderr '^go: example.com/m imports\n\texample.com/badimport imports\n\texample.net/oops: cannot find module providing package example.net/oops$'
10cmp go.mod.orig go.mod
11
12cd importsyntax
13
14
15# A syntax error in a dependency prevents the compiler from needing that
16# dependency's imports, so 'go get' should not report an error when those
17# imports cannot be resolved: it has all of the dependencies that the compiler
18# needs, and the user did not request to run the compiler.
19
20go get
21cmp ../go.mod.syntax-d ../go.mod
22
23
24-- go.mod --
25module example.com/m
26
27go 1.16
28
29replace example.com/badimport v0.1.0 => ./badimport
30-- go.mod.syntax-d --
31module example.com/m
32
33go 1.16
34
35replace example.com/badimport v0.1.0 => ./badimport
36
37require example.com/badimport v0.1.0
38-- m.go --
39package m
40
41import _ "example.com/badimport"
42-- importsyntax/importsyntax.go --
43package importsyntax
44
45import _ "example.com/badimport/syntaxerror"
46-- badimport/go.mod --
47module example.com/badimport
48
49go 1.16
50-- badimport/badimport.go --
51package badimport
52
53import "example.net/oops"
54-- badimport/syntaxerror/syntaxerror.go --
55pack-age syntaxerror // sic
56
57import "example.net/oops"
View as plain text