cp go.mod go.mod.orig env oldGOPROXY=$GOPROXY # If a wildcard replacement exists for an otherwise-nonexistent module, # 'go get' should resolve it to the minimum valid pseudo-version. go mod edit -replace=example.com/x=./x go get example.com/x go list -m example.com/x stdout '^example.com/x v0.0.0-00010101000000-000000000000 ' # If specific-version replacements exist, the highest matching version should be used. go mod edit -replace=example.com/x@v0.1.0=./x go mod edit -replace=example.com/x@v0.2.0=./x go get example.com/x go list -m example.com/x stdout '^example.com/x v0.2.0 ' go get example.com/x@v1.3.1 go list -m rsc.io/quote stdout '^rsc.io/quote v1.4.0' # Replacements should allow 'go get' to work even with dotless module paths. cp go.mod.orig go.mod ! go list example stderr '^package example is not in GOROOT \(.*\)$' ! go get example stderr '^go: malformed module path "example": missing dot in first path element$' go mod edit -replace example@v0.1.0=./example ! go list example stderr '^module example provides package example and is replaced but not required; to add it:\n\tgo get example@v0.1.0$' go get example go list -m example stdout '^example v0.1.0 ' -- go.mod -- module example.com go 1.16 -- x/go.mod -- module example.com/x go 1.16 -- x/x.go -- package x -- example/go.mod -- module example go 1.16 -- example/example.go -- package example