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:~$
相关推荐
紧跟先前的步伐1 天前
Go AI Agent 实战 28|Agent 的预算、超时与停止条件
开发语言·人工智能·后端·ai·golang
且从容.1 天前
Ubuntu 安装 Docker
linux·ubuntu·docker
利威尔xu1 天前
2026-11-05-Go内存管理面试
面试·golang
承渊政道2 天前
Linux网络学习【深入理解多路转接select、poll的代码改写】
linux·ubuntu·select·多路转接·poll
Zenova EdgeOS3 天前
Go 工业边缘错误处理实战:用 errors 构建可追溯错误链
开发语言·数据库·golang
JavaPub-rodert3 天前
从零搭建通用管理后台:ShiyuAdmin 的 Go、React 与 RBAC 实践
开发语言·react.js·golang
沫璃染墨3 天前
从零入门计算机网络系列(十二):HTTP长连接与会话管理详解——从Connection到Cookie与Session
linux·服务器·c++·tcp/ip·ubuntu·http·交互
longzhizhui9263 天前
Ubuntu 全版本 CVE-2026-98432 内核安全升级操作手册
ubuntu·网络安全·云计算·bash
microrain3 天前
SagooIoT 的数据接入层只有四张表,却能接住三种外部数据
物联网·golang·数据建模·sagooiot
fly-iot3 天前
【FDE知识库】(4):企业知识库怎么选型,开源知识库分享几个,选择开源协议友好的版本,开发wiki-go项目
golang·开源·开源协议