fix(go): preserve ~/go across version upgrades#1057
Draft
Conversation
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>
Copilot
AI
changed the title
[WIP] Fix Go installer to preserve globally installed tools
fix(go): preserve ~/go across version upgrades
Mar 12, 2026
coolaj86
reviewed
Mar 12, 2026
| # 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" | ||
| if [ ! -e "$GOBIN" ] && [ ! -L "$GOBIN" ]; then |
coolaj86
reviewed
Mar 12, 2026
| if [ ! -e "$GOBIN" ] && [ ! -L "$GOBIN" ]; then | ||
| # New install: create ~/go as a real directory (not a symlink) | ||
| mkdir -p "$GOBIN/bin" | ||
| elif [ -L "$GOBIN" ]; then |
Member
There was a problem hiding this comment.
@copilot It looks like an early return would be well-suited here
Author
There was a problem hiding this comment.
Done in 3cb1dc6 — pkg_link() is now flat with early returns for each case (not exists, real dir, already stable symlink, versioned symlink migration, broken symlink).
Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
Co-authored-by: coolaj86 <122831+coolaj86@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
go/install.shpkg_link()to keep~/gostable across version upgradesgolang/install.shtestinstead of[ ... ]per codebase conventionpkg_link()to use early returns instead of nestedelifOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.