How to install golang 1.26.0 to Ubuntu 24.04

Download

bash 复制代码
wget -c https://go.dev/dl/go1.26.0.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local

Or

bash 复制代码
sudo tar -C /usr/local/ -xzf go1.26.0.linux-amd64.tar.gz

Configuration

Add the go_path variable to the configuration file

bash 复制代码
sudo touch /etc/profile.d/go.sh
sudo tee /etc/profile.d/go.sh <<-'EOF'
export GOROOT=/usr/local/go
#export GOPATH=~/go
#export PATH=$PATH:$GOROOT/bin:$GOPATH
export PATH=$PATH:$GOROOT/bin
#export GO111MODULE=on
#export GOPROXY=https://goproxy.cn,direct
EOF

Enable the ability to automatically append GOPATH at boot

bash 复制代码
tee -a ~/.bashrc <<-'EOF'
if [ -f /etc/profile.d/go.sh ]; then
    . /etc/profile.d/go.sh
fi
EOF

Make environment variables take effect

bash 复制代码
source .bashrc

Verification

Verification results

bash 复制代码
lwk@qwfys:~$ echo $GOPATH

lwk@qwfys:~$ echo $GOROOT
/usr/local/go
lwk@qwfys:~$ go version
go version go1.26.0 linux/amd64
lwk@qwfys:~$ go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/lwk/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/lwk/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3874236230=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/lwk/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/lwk/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/lwk/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.0'
GOWORK=''
PKG_CONFIG='pkg-config'
lwk@qwfys:~$
相关推荐
XIAOHEZIcode1 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
何以解忧,唯有..14 天前
Go语言循环语句详解:for、range与循环控制
开发语言·算法·golang
张飞飞飞飞飞14 天前
Tmux命令使用教程
linux·服务器·ubuntu
踏着七彩祥云的小丑14 天前
Go学习第9天:并发编程 + 文件操作 + 正则表达式
学习·golang·正则表达式·go
JCGKS14 天前
Go `init` 函数:包初始化顺序到底是怎样的
golang·init·init执行顺序
何以解忧,唯有..14 天前
Go语言中的const:常量声明与iota枚举详解
java·开发语言·golang
盼小辉丶14 天前
Ubuntu极速部署OpenClaw完全指南(本地模型+DeepSeek)
linux·ubuntu·openclaw
黑白园14 天前
【环境搭建】Ubuntu安装(一)
linux·ubuntu
Moshow郑锴14 天前
Ubuntu用SDKMAN轻松管理多个Java 版本
java·ubuntu·sdkman
geovindu14 天前
go: Reactor Pattern
开发语言·后端·设计模式·golang·反应器模式