Removing Golang from Ubuntu

Hey! If you love Go and building Go apps as much as I do, let's connect on Twitter or LinkedIn. I talk about this stuff all the time!

Want to learn how to build better Go applications faster and easier? You can.

Check out my course on the Go Standard Library. You can check it out now for free.


Learn how to remove Go and its dependencies from your Ubuntu system with this comprehensive guide.




Introduction

Golang, or Go, is a popular programming language that has gained significant traction in recent years. It’s known for its simplicity, readability, and performance, making it a great choice for building scalable and concurrent systems. If you’ve decided to use Go on your Ubuntu system but now want to remove it, this guide will help you through the process.

Step 1: Check Your Go Version

Before uninstalling Go, make sure you know which version of Go is installed on your system. You can check the version by running the following command in your terminal:

go version

This will output something like Go 1.17.4 if you have Go installed. Take note of the version number, as you’ll need it later to uninstall Go.

Step 2: Remove Go

To remove Go from your Ubuntu system, you can use the following command:

sudo apt-get purge golang*

This will remove all packages related to Go on your system. However, this command will also remove any other dependencies that were installed along with Go, which may not be desirable. If you want to keep these dependencies intact and only remove Go itself, use the following command instead:

sudo apt-get purge golang-go

This will remove only the golang-go package and any dependencies that were installed along with it.

Step 3: Remove Dependencies

If you want to completely remove Go and all of its dependencies, use the following command:

sudo apt-get autoremove

This will remove all packages related to Go on your system, including any dependencies that were installed along with it.

Step 4: Remove the go Command

After removing Go and its dependencies, you’ll need to remove the go command from your system. You can do this by running the following command in your terminal:

sudo rm /usr/bin/go

This will delete the go binary file, which should now be gone from your system.

Conclusion

Removing Go from your Ubuntu system is a straightforward process that involves using the apt-get purge command to remove the golang* packages and any dependencies that were installed along with it. If you want to completely remove all traces of Go, including its dependencies, use the autoremove command after removing the go binary file. With these steps, you should be able to safely uninstall Go from your Ubuntu system.


Questions or comments? Reach out to me


Learn how to leverage the Go Standard Library like a PRO.

I just created a new course, The Go Standard Library, check it out!