Compare commits

...

4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot]
3cb1dc619e fix(go): use early returns in pkg_link for clarity
Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
2026-03-12 08:28:36 +00:00
copilot-swe-agent[bot]
cd7948c81f fix(go): use test instead of [ ... ] in pkg_link
Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
2026-03-12 08:26:57 +00:00
copilot-swe-agent[bot]
d875787ef1 fix(go): preserve ~/go across version upgrades
Previously, each `go install` upgrade would create a new versioned
`go-bin-vX.Y.Z` directory and symlink `~/go` to it, effectively
hiding all globally-installed Go tools on every upgrade.

New behavior in pkg_link():
- New install: create ~/go as a real directory (not a symlink)
- Existing versioned symlink: rename go-bin-vX.Y.Z to the stable
  unversioned path ~/.local/opt/go-bin, preserving all installed tools
- Already migrated (symlink to go-bin) or real dir: leave untouched
- Broken symlink: recreate ~/go as a real directory

Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
2026-03-12 08:22:32 +00:00
copilot-swe-agent[bot]
cdb8c775df Initial plan 2026-03-12 08:17:33 +00:00
2 changed files with 72 additions and 14 deletions

View File

@@ -3,7 +3,6 @@ set -e
set -u
GOBIN="${HOME}/go"
GOBIN_REAL="${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
pkg_cmd_name="go"
@@ -37,13 +36,43 @@ pkg_link() {
rm -rf "$pkg_dst"
ln -s "$pkg_src" "$pkg_dst"
# Go has a special $GOBIN
# Go's package directory (GOPATH) at ~/go must persist across version
# upgrades. Unlike other tools, go-installed binaries are shared across
# all Go versions, so ~/go is kept stable rather than being swapped to a
# versioned directory on each upgrade.
b_gobin_stable="${HOME}/.local/opt/go-bin"
# 'GOBIN' is set above to "${HOME}/go"
# 'GOBIN_REAL' will be "${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
rm -rf "$GOBIN"
mkdir -p "$GOBIN_REAL/bin"
ln -s "$GOBIN_REAL" "$GOBIN"
# New install: create ~/go as a real directory (not a symlink)
if ! test -e "$GOBIN" && ! test -L "$GOBIN"; then
mkdir -p "$GOBIN/bin"
return
fi
# Real directory: leave it alone
if ! test -L "$GOBIN"; then
return
fi
b_old_target="$(readlink "$GOBIN")"
# Already pointing to the stable unversioned dir: nothing to do
if test "$b_old_target" = "$b_gobin_stable"; then
return
fi
# Migrate from old versioned-symlink (e.g. go-bin-v1.14.2):
# rename the versioned directory to the stable unversioned path
# so that all installed tools are preserved on upgrade.
if test -d "$b_old_target"; then
mv "$b_old_target" "$b_gobin_stable"
rm -f "$GOBIN"
ln -s "$b_gobin_stable" "$GOBIN"
return
fi
# Symlink target is gone; recreate ~/go as a real directory
rm -f "$GOBIN"
mkdir -p "$GOBIN/bin"
}
pkg_post_install() {

View File

@@ -3,7 +3,6 @@ set -e
set -u
GOBIN="${HOME}/go"
GOBIN_REAL="${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
pkg_cmd_name="go"
@@ -37,13 +36,43 @@ pkg_link() {
rm -rf "$pkg_dst"
ln -s "$pkg_src" "$pkg_dst"
# Go has a special $GOBIN
# Go's package directory (GOPATH) at ~/go must persist across version
# upgrades. Unlike other tools, go-installed binaries are shared across
# all Go versions, so ~/go is kept stable rather than being swapped to a
# versioned directory on each upgrade.
b_gobin_stable="${HOME}/.local/opt/go-bin"
# 'GOBIN' is set above to "${HOME}/go"
# 'GOBIN_REAL' will be "${HOME}/.local/opt/go-bin-v${WEBI_VERSION}"
rm -rf "$GOBIN"
mkdir -p "$GOBIN_REAL/bin"
ln -s "$GOBIN_REAL" "$GOBIN"
# New install: create ~/go as a real directory (not a symlink)
if ! test -e "$GOBIN" && ! test -L "$GOBIN"; then
mkdir -p "$GOBIN/bin"
return
fi
# Real directory: leave it alone
if ! test -L "$GOBIN"; then
return
fi
b_old_target="$(readlink "$GOBIN")"
# Already pointing to the stable unversioned dir: nothing to do
if test "$b_old_target" = "$b_gobin_stable"; then
return
fi
# Migrate from old versioned-symlink (e.g. go-bin-v1.14.2):
# rename the versioned directory to the stable unversioned path
# so that all installed tools are preserved on upgrade.
if test -d "$b_old_target"; then
mv "$b_old_target" "$b_gobin_stable"
rm -f "$GOBIN"
ln -s "$b_gobin_stable" "$GOBIN"
return
fi
# Symlink target is gone; recreate ~/go as a real directory
rm -f "$GOBIN"
mkdir -p "$GOBIN/bin"
}
pkg_post_install() {