...
1# Regression test for https://golang.org/issue/46659.
2#
3# If a 'replace' directive specifies an older-than-selected version of a module,
4# 'go mod tidy' shouldn't try to add that version to the build list to resolve a
5# missing package: it won't be selected, and would cause the module loader to
6# loop indefinitely trying to resolve the package.
7
8cp go.mod go.mod.orig
9
10! go mod tidy
11! stderr panic
12stderr '^go: golang\.org/issue46659 imports\n\texample\.com/missingpkg/deprecated: package example\.com/missingpkg/deprecated provided by example\.com/missingpkg at latest version v1\.0\.0 but not at required version v1\.0\.1-beta$'
13
14go mod tidy -e
15
16cmp go.mod go.mod.orig
17
18-- go.mod --
19module golang.org/issue46659
20
21go 1.17
22
23replace example.com/missingpkg v1.0.1-alpha => example.com/missingpkg v1.0.0
24
25require example.com/usemissingpre v1.0.0
26
27require example.com/missingpkg v1.0.1-beta // indirect
28-- m.go --
29package m
30
31import (
32 _ "example.com/missingpkg/deprecated"
33 _ "example.com/usemissingpre"
34)
View as plain text