]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go: use Join functions instead of adding path separators to strings
authorBryan C. Mills <bcmills@google.com>
Fri, 20 Jan 2023 21:25:33 +0000 (16:25 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 31 Jan 2023 20:33:02 +0000 (20:33 +0000)
commit5f00ce86334aa7e80ab825882db1a080f1b56404
treeaea0f001cf2164b02a27cda9449d17d356c13a2a
parentde2efc2aa1448cfcf28fec66ce0ff3f979fc2f12
cmd/go: use Join functions instead of adding path separators to strings

Adding a file path separator is incorrect for a file path that may be
the root directory on a Unix platform (such as in a container or
chroot).

Adding a path separator is incorrect for a package path prefix that
may be the empty string (as in the "std" module in GOROOT/src).

And in both cases, a Join function is arguably clearer and simpler
anyway.

Fixes #51506 (maybe).

Change-Id: Id816930811ad5e4d1fbd206cddf219ecd4ad39a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/463178
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
12 files changed:
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/modindex/build.go
src/cmd/go/internal/modload/load.go
src/cmd/go/internal/modload/search.go
src/cmd/go/internal/script/cmds.go
src/cmd/go/internal/script/state.go
src/cmd/go/internal/search/search.go
src/cmd/go/internal/str/path.go
src/cmd/go/internal/work/action.go
src/cmd/go/testdata/addmod.go
src/cmd/go/testdata/savedir.go