Install Go via APT on Debian | Generated by AI
To install Go using apt on a Debian-based Linux system (e.g., Ubuntu), follow these steps. Note that apt may install an older version of Go (e.g., 1.18 on Ubuntu 22.04), so you should verify if it meets your project’s requirements (check the go.mod file in ~/Projects/clash-core for the required Go version).
Steps to Install Go Using APT
- Update the Package Index
- Ensure your package lists are up to date:
sudo apt update
- Ensure your package lists are up to date:
- Install Go
- Install the Go package:
sudo apt install golang-go - This installs the Go compiler, tools, and standard library.
- Install the Go package:
- Verify the Installation
- Check the installed Go version:
go version - You should see output like:
go version go1.18.1 linux/amd64(The version depends on your distribution’s package repository.)
- Check the installed Go version:
- Set Up GOPATH (Optional)
- Modern Go versions (1.13+) use modules, so
GOPATHis optional, but setting it can be useful for some projects. - Edit your shell profile (e.g.,
~/.bashrcor~/.zshrc):nano ~/.bashrc - Add the following:
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin - Save and reload the shell configuration:
source ~/.bashrc
- Modern Go versions (1.13+) use modules, so
- Retry the Build
- Navigate to your project directory:
cd ~/Projects/clash-core - Run the
makecommand again:make
- Navigate to your project directory:
Notes
- Version Check: If your project requires a newer Go version (e.g., 1.20 or later), the
aptversion might be outdated. Check the required version ingo.modor the project’s documentation. If needed, install a newer version manually by downloading the tarball from https://go.dev/dl/ (as described in the previous response). - Alternative Repositories: For a newer version via
apt, you can add a third-party PPA (e.g.,ppa:longsleep/golang-backportson Ubuntu). Run:sudo add-apt-repository ppa:longsleep/golang-backports sudo apt update sudo apt install golang-go - Troubleshooting:
- If
gois not found, ensure/usr/bin/goexists (ls /usr/bin/go). If not, reinstall withsudo apt install --reinstall golang-go. - If you get dependency errors, run
sudo apt install -fto fix them. - For permission issues, ensure you have
sudoprivileges.
- If
Sources
- Ubuntu Go installation guide: https://ubuntu.com/server/docs/programming-go
- General apt usage: https://help.ubuntu.com/community/AptGet/Howto
If the installed version is too old or you encounter issues, let me know your Linux distribution (e.g., Ubuntu 22.04) and the required Go version, and I’ll guide you further!