X

Install Go on Debian 10/11

2021/12/16
  1. 第一步依旧是更新
# ensure all backups are up-to-date. 
$ sudo apt update 

  1. 安装下载工具
$ sudo apt install wget -y

  1. 下载最新版 Visit the Go Language download page to download the latest version of Go. Alternatively, you can download the Go language binary package via terminal using the following command.
$ wget https://go.dev/dl/go1.17.5.linux-amd64.tar.gz

  1. 解压

    # Extract the archive to /usr/local.
    $ sudo tar -zxvf go1.17.*linux-amd64.tar.gz -C /usr/local/
    
  2. 设置环境变量

# Setup Go Environment
$ echo "export PATH=/usr/local/go/bin:${PATH}" | sudo tee /etc/profile.d/go.sh
$ source /etc/profile.d/go.sh

  1. 检查安装
    # Verify Go Installation
    $ go version
    
    Output:
go version go1.17.5 linux/amd64
$ go env

Output:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2793055800=/tmp/go-build -gno-record-gcc-switches"
Commit