5

Linux下安装Go环境

 3 years ago
source link: https://studygolang.com/articles/13957?fr=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

登录Linux

Mac或Linux的用户可以用命令ssh [email protected]登录主机
Window的用户可以使用SecureCRT登录主机
虚拟机用户直接打开你的虚拟机

安装Go环境

Golang官网下载地址:https://golang.org/dl/

  1. 打开官网下载地址选择对应的系统版本, 复制下载链接
    这里我选择的是
    go1.10.3.linux-amd64.tar.gzhttps://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
1277729-ea51a0394693c7a3.png
  1. cd进入你用来存放安装包的目录。嫌麻烦就直接输入cd ~
    然后执行
wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
1277729-e8fecfe5869748d4.png
  1. 执行tar解压到/usr/loacl目录下,得到go文件夹
tar -C /usr/local -zxvf  go1.10.3.linux-amd64.tar.gz
  1. 添加/usr/loacl/go/bin目录到PATH变量中。添加到/etc/profile$HOME/.profile都可以
// 习惯用vim,没有的话可以用命令`sudo apt-get install vim`安装一个
vim /etc/profile
// 在最后一行添加
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin
// wq保存退出后source一下
source /etc/profile
  1. 执行go version,如果现实版本号,则Go环境安装成功。是不是很简单呢?
    1277729-26270444b9f95d52.png

运行第一个程序

先留个坑,后面再填


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK