linux下安装golang

  1. 下载golang源码安装包
    wget https://dl.google.com/go/go1.12.1.linux-amd64.tar.gz
    
  2. 解压文件
    tar -zxvf go1.12.1.linux-amd64.tar.gz -C /usr/local/bin/
    
  3. 配置环境变量
    echo "export GOROOT=/usr/local/bin/go/" >> ~/.bashrc
    echo "export PATH=$GOROOT/bin:$PATH" >> ~/.bashrc
    echo "export GOPATH=$HOME/work/go" >> ~/.bashrc
    echo "export PATH=$PATH:$GOPATH/bin" >> ~/.bashrc
    source ~/.bashrc
    
  4. 测试安装是否成功

    [root@iZ2ze40depfadmv9xdxdsxZ src]# go version
    go version go1.12.1 linux/amd64
    

你可能感兴趣的:(linux下安装golang)