1. Windows 安装

  1. 访问 https://golang.org/dl/
  2. 下载
  3. 按照下面流程安装
  • 官网流程:
  1. Open the MSI file you downloaded and follow the prompts to install Go.By default, the installer will install Go to Program Files or Program Files (x86). You can change the location as needed. After installing, you will need to close and reopen any open command prompts so that changes to the environment made by the installer are reflected at the command prompt.
  2. Verify that you’ve installed Go.
    1. In Windows, click the Start menu.
    2. In the menu’s search box, type cmd, then press the Enter key.
    3. In the Command Prompt window that appears, type the following command:
      1. $ go version

d. Confirm that the command prints the installed version of Go.

  1. 打开安装包,选择 next

image.png

  1. 点击 next

image.png

  1. 选择默认安装路径,点击 next

image.png

  1. 点击 install

image.png

  1. 打开 cmd
    1. C:\Users\zhi'yong>go version
    2. go version go1.16.3 windows/amd64

2. Linux 安装

  1. 下载:

    https://golang.org

选择 Downliad Go
00. go 安装 - 图5

  1. 指定目录解压

    1. rm -rf /usr/local/go && tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz
  2. 修改 ~/.bashrc

    1. # golang
    2. # go 语言的根目录
    3. export GOROOT=/usr/local/go
    4. # go 语言的工作目录
    5. export GOPATH=$HOME/go
    6. # 加入到环境变量
    7. export PATH=$PATH:$GOROOT/bin
  3. source ~/.bashrc

  4. go version

    1. chenzy@chen211:~/zhiyong/go/bin> go version
    2. go version go1.15.6 linux/amd64