How to update Go version later?

QuestionsQuestions8 SkillsProDec, 15 2025
0185

Hello!

You're asking a great question about managing your Go environment. While the LabEx VM comes with a pre-installed Go version (currently 1.20.1 for this lab), if you were working on your own local machine and wanted to update your Go version, here's the general process:

  1. Download the new version:
    Go to the official Go download page: https://go.dev/dl/
    Download the appropriate archive for your operating system (e.g., go1.21.x.linux-amd64.tar.gz for Linux).

  2. Remove the old installation (Optional but Recommended):
    If you've installed Go previously, it's often best to remove the old installation directly.
    Typically, Go is installed in /usr/local/go. You can remove it with:

    sudo rm -rf /usr/local/go

    Be careful when using sudo rm -rf as it permanently deletes files.

  3. Extract the new archive:
    Extract the downloaded archive to /usr/local (or your preferred installation location):

    sudo tar -C /usr/local -xzf go1.21.x.linux-amd64.tar.gz

    This command extracts the contents of the archive into /usr/local, creating a new go directory (e.g., /usr/local/go).

  4. Set/Update your PATH environment variable:
    You need to ensure that the go command is in your system's PATH.
    Add the following line to your shell's profile file (e.g., ~/.bashrc, ~/.zshrc, or ~/.profile):

    export PATH=$PATH:/usr/local/go/bin

    After adding it, you'll need to source your profile file or open a new terminal session for the changes to take effect:

    source ~/.bashrc # or whichever file you edited
  5. Verify the installation:
    Open a new terminal and check the Go version:

    go version

    This should now show the newly installed version (e.g., go version go1.21.x linux/amd64).

Important Note for LabEx: For the current lab environment, the Go version is managed by LabEx. You generally won't need to perform these steps yourself within the lab. If a lab requires a different Go version, it will either be pre-configured, or the lab instructions will guide you on how to set up a specific version if necessary.

For this "Beginner's Guide to Go Programming" lab, Go 1.20.1 is sufficient for all the intended learning outcomes. If you have any specific code issues due to the Go version, I can definitely help you adapt it!

0 Comments

no data
Be the first to share your comment!