Ubuntu 安装 Golang

环境:

  • VMware 15.5.1中安装的 Ubuntu 18

安装

  • 终端执行命令

    sudo apt-get install golang
    

    在这里插入图片描述

  • 安装完成后你可以查看版本号,这里默认安装最新版本
    在这里插入图片描述

  • 配置环境变量,执行sudo gedit /etc/profile将下面代码添加至 /etc/profile文件末尾,(也可以添加至 ~/.bashrc文件里)

    export GOPATH=/home/GO_PATH   //用于go的工作目录
    export GOROOT=/usr/lib/go-1.10  //安装目录
    PATH=$GOROOT/bin:$PATH
    

    每个人的安装可能目录不一样,所以要适当更改。
    ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200520102653700.png
    在这里插入图片描述
    然后生效更改

    source /etc/profile
    . /etc/profile
    
  • 检测是否成功

    go env
    

    在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41822224/article/details/106229627