| 1 |
cp 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 |
| 9 |
stderr '^go: example.com/m imports\n\texample.com/badimport imports\n\texample.net/oops: cannot find module providing package example.net/oops$' |
| 10 |
cmp go.mod.orig go.mod |
| 11 |
|
| 12 |
cd 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 |
|
| 20 |
go get |
| 21 |
cmp ../go.mod.syntax-d ../go.mod |
| 22 |
|
| 23 |
|
| 24 |
-- go.mod -- |
| 25 |
module example.com/m |
| 26 |
|
| 27 |
go 1.16 |
| 28 |
|
| 29 |
replace example.com/badimport v0.1.0 => ./badimport |
| 30 |
-- go.mod.syntax-d -- |
| 31 |
module example.com/m |
| 32 |
|
| 33 |
go 1.16 |
| 34 |
|
| 35 |
replace example.com/badimport v0.1.0 => ./badimport |
| 36 |
|
| 37 |
require example.com/badimport v0.1.0 |
| 38 |
-- m.go -- |
| 39 |
package m |
| 40 |
|
| 41 |
import _ "example.com/badimport" |
| 42 |
-- importsyntax/importsyntax.go -- |
| 43 |
package importsyntax |
| 44 |
|
| 45 |
import _ "example.com/badimport/syntaxerror" |
| 46 |
-- badimport/go.mod -- |
| 47 |
module example.com/badimport |
| 48 |
|
| 49 |
go 1.16 |
| 50 |
-- badimport/badimport.go -- |
| 51 |
package badimport |
| 52 |
|
| 53 |
import "example.net/oops" |
| 54 |
-- badimport/syntaxerror/syntaxerror.go -- |
| 55 |
pack-age syntaxerror // sic |
| 56 |
|
| 57 |
import "example.net/oops" |