Pull in CL 500335. It teaches modfile.IsDirectoryPath to recognize all
relative paths that begin with a "." or ".." path element as a valid
directory path (rather than a module path). This allows removing the
path == "." check that CL 389298 added to modload.ToDirectoryPath.
go get golang.org/x/mod@
6e58e47c # CL 500335
go mod tidy
go mod vendor
Updates #51448.
Fixes #60572.
Change-Id: Ide99c728c8dac8fd238e13f6d6a0c3917d7aea2d
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/500355
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
require (
github.com/google/pprof v0.0.0-20230811205829-9131a7e9cc17
golang.org/x/arch v0.5.1-0.20231011141335-a6bdeed49307
- golang.org/x/mod v0.13.0
+ golang.org/x/mod v0.13.1-0.20231025225536-6e58e47c7bd6
golang.org/x/sync v0.4.1-0.20231011140417-10739b037d36
golang.org/x/sys v0.13.1-0.20231011215430-1bfbee0e20e3
golang.org/x/term v0.13.1-0.20231011140651-6a610bc55bff
github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
golang.org/x/arch v0.5.1-0.20231011141335-a6bdeed49307 h1:1nIbNxjxQ3+dss3xYMxayoIZONazUTg8/BENwc19sAQ=
golang.org/x/arch v0.5.1-0.20231011141335-a6bdeed49307/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
-golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
-golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
+golang.org/x/mod v0.13.1-0.20231025225536-6e58e47c7bd6 h1:YSyE+/SK6vfYAxf27iVtUZ/tTZOHGN6epnMgE1al/+M=
+golang.org/x/mod v0.13.1-0.20231025225536-6e58e47c7bd6/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.4.1-0.20231011140417-10739b037d36 h1:+lDu3sHZVY5Qqb7ynMbjaT4IsYicvoxypEOIE4aYlYE=
golang.org/x/sync v0.4.1-0.20231011140417-10739b037d36/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.13.1-0.20231011215430-1bfbee0e20e3 h1:G9se7UpoI67yWrFY0IIFGf6H3nwLLUZFDBCyOJwWeSc=
// an absolute path or a relative path starting with a '.' or '..'
// path component.
func ToDirectoryPath(path string) string {
- if path == "." || modfile.IsDirectoryPath(path) {
+ if modfile.IsDirectoryPath(path) {
return path
}
// The path is not a relative path or an absolute path, so make it relative
# Regression test for https://go.dev/issue/51448.
-# 'go work init . foo/bar' should produce a go.work file
-# with the same paths as 'go work init; go work use -r .'.
+# 'go work init . .. foo/bar' should produce a go.work file
+# with the same paths as 'go work init; go work use -r ..',
+# and it should have 'use .' rather than 'use ./.' inside.
-go work init . foo/bar
+cd dir
+
+go work init . .. foo/bar
mv go.work go.work.init
go work init
-go work use -r .
+go work use -r ..
cmp go.work go.work.init
+cmpenv go.work $WORK/go.work.want
+
-- go.mod --
module example
go 1.18
--- foo/bar/go.mod --
+-- dir/go.mod --
module example
go 1.18
+-- dir/foo/bar/go.mod --
+module example
+go 1.18
+-- $WORK/go.work.want --
+go $goversion
+
+use (
+ .
+ ..
+ ./foo/bar
+)
if strings.Contains(ns, "@") {
return nil, errorf("replacement module must match format 'path version', not 'path@version'")
}
- return nil, errorf("replacement module without version must be directory path (rooted or starting with ./ or ../)")
+ return nil, errorf("replacement module without version must be directory path (rooted or starting with . or ..)")
}
if filepath.Separator == '/' && strings.Contains(ns, `\`) {
return nil, errorf("replacement directory appears to be Windows path (on a non-windows system)")
}
if IsDirectoryPath(ns) {
return nil, errorf("replacement module directory path %q cannot have version", ns)
-
}
}
return &Replace{
}
}
-// IsDirectoryPath reports whether the given path should be interpreted
-// as a directory path. Just like on the go command line, relative paths
+// IsDirectoryPath reports whether the given path should be interpreted as a directory path.
+// Just like on the go command line, relative paths starting with a '.' or '..' path component
// and rooted paths are directory paths; the rest are module paths.
func IsDirectoryPath(ns string) bool {
// Because go.mod files can move from one system to another,
// we check all known path syntaxes, both Unix and Windows.
- return strings.HasPrefix(ns, "./") || strings.HasPrefix(ns, "../") || strings.HasPrefix(ns, "/") ||
- strings.HasPrefix(ns, `.\`) || strings.HasPrefix(ns, `..\`) || strings.HasPrefix(ns, `\`) ||
+ return ns == "." || strings.HasPrefix(ns, "./") || strings.HasPrefix(ns, `.\`) ||
+ ns == ".." || strings.HasPrefix(ns, "../") || strings.HasPrefix(ns, `..\`) ||
+ strings.HasPrefix(ns, "/") || strings.HasPrefix(ns, `\`) ||
len(ns) >= 2 && ('A' <= ns[0] && ns[0] <= 'Z' || 'a' <= ns[0] && ns[0] <= 'z') && ns[1] == ':'
}
golang.org/x/arch/arm64/arm64asm
golang.org/x/arch/ppc64/ppc64asm
golang.org/x/arch/x86/x86asm
-# golang.org/x/mod v0.13.0
+# golang.org/x/mod v0.13.1-0.20231025225536-6e58e47c7bd6
## explicit; go 1.18
golang.org/x/mod/internal/lazyregexp
golang.org/x/mod/modfile