Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: Go Self Upgrade #60848

Closed
Nasfame opened this issue Jun 16, 2023 · 3 comments
Closed

cmd/go: Go Self Upgrade #60848

Nasfame opened this issue Jun 16, 2023 · 3 comments
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@Nasfame
Copy link
Contributor

Nasfame commented Jun 16, 2023

Proposal: Self-upgrade Tool for Go

Proposal Description

The proposal suggests adding a new tool to the Go toolchain that allows users to self-upgrade their Go installations to the latest version. Currently, upgrading Go requires manual steps such as downloading the latest release, replacing the existing installation, and updating environment variables. This proposal aims to simplify the upgrade process and provide a built-in mechanism for users to easily upgrade their Go installations.

Motivation

The motivation behind this proposal is to improve the user experience and streamline the process of upgrading Go to the latest version. By providing a self-upgrade tool, users can avoid the need to manually download and install the latest release. This tool would handle the necessary steps, including fetching the latest version, performing the installation, and updating relevant environment variables.

Proposed Solution

The proposed solution is to introduce a new command in the Go toolchain, such as go upgrade, that automates the process of upgrading Go. When invoked, the go upgrade command would:

  1. Check for the latest available version of Go.
  2. Download the latest release package.
  3. Perform the installation, replacing the existing Go installation.
  4. Update relevant environment variables, such as GOROOT and PATH, to point to the new installation.

This tool should be platform-independent and work seamlessly on various operating systems supported by Go.

Drawbacks

There may be a few considerations and drawbacks to be aware of with this proposal:

  1. Network Dependency: The self-upgrade tool would require an internet connection to check for the latest version and download the release package.
  2. Permissions: Depending on the user's system configuration, the tool may require appropriate permissions to replace the existing Go installation and modify environment variables.

Alternatives

As an alternative to a built-in self-upgrade tool, users can rely on third-party tools or package managers that offer Go version management. These tools, such as gvm, gimme, or asdf, provide features for managing multiple Go versions and simplifying the upgrade process.

Conclusion

Introducing a self-upgrade tool in the Go toolchain can greatly enhance the user experience and simplify the process of upgrading Go to the latest version. By automating the upgrade steps, users can stay up-to-date with the latest features, bug fixes, and security patches without the need for manual intervention.

This proposal seeks feedback and discussion from the Go community to determine the feasibility and potential implementation details of such a self-upgrade tool.

Please share your thoughts, comments, and suggestions regarding this proposal.

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 16, 2023
@gopherbot gopherbot added this to the Unreleased milestone Jun 16, 2023
@ianlancetaylor
Copy link
Contributor

Related to #57001. Perhaps a dup.

@findleyr findleyr changed the title x/tools/gopls: Go Self Upgrade cmd/go: Go Self Upgrade Jun 16, 2023
@findleyr findleyr removed the gopls Issues related to the Go language server, gopls. label Jun 16, 2023
@qiulaidongfeng
Copy link
Contributor

It should not be dup #57001.

The automatic download of the new Toolchain of the #57001 proposal extends forward compatibility. This proposal downloads the new Toolchain in order to replace the old Toolchain with the new Toolchain.

When I first started using go, because upgrading the Toolchain requires manual download, decompression and replacement, only the minor version number plus 1 will update the Toolchain. If go can automatically update the Toolchain, it can really enhance the user experience.

Now, gotip can be used to install the latest Toolchain, but when installing the go Toolchain of the specified release version, I think the specified version (take 1.20 as an example) is used to go install golang.org/dl/1.20@latest This is a solution that needs to be improved, because it only automates the download and decompression of the Toolchain to the local computer, and can use the go+version command to call the Toolchain.

I think we can refer to the Go version manager github.com/owenthereal/goup
goup install version is used to install the tool chain
goup remove version is used to delete a tool chain
goup list is a tool chain used to display the installation
goup set version is used to set the version of the toolchain used when the go command is invoked
This makes it easy for users to upgrade go to the new version.

@seankhliao
Copy link
Member

Duplicate of #27700

@seankhliao seankhliao marked this as a duplicate of #27700 Jun 19, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

6 participants