在linux云服务器下配置GoLang环境

栏目: Go · 发布时间: 5年前

内容简介:当然你如果可以翻墙还可以去这个网址下载下载对应版本的包

1、下载 go 环境: Golang

当然你如果可以翻墙还可以去这个网址下载 https://golang.org/dl/

下载对应版本的包

在 <a href='https://www.codercto.com/topics/18170.html'>linux</a> 云服务器下配置GoLang环境

2、上传下载的文件

scp /Users/zt/Desktop/go1.11.2.linux-amd64.tar.gz hz@94.191.79.156:/home/hz/桌面

在linux云服务器下配置GoLang环境

3、给用户添加权限

(1)在root用户下运行vim /etc/sudoers

在linux云服务器下配置GoLang环境

添加:对应的用户名添加权限,我的是hz

在linux云服务器下配置GoLang环境

4、在服务器上解压缩

在linux云服务器下配置GoLang环境

成功后去用户/usr/local查看有没有对应的go文件夹

在linux云服务器下配置GoLang环境

5、配置go

终端下输入cd 进如当前用户主目录

vim .bashrc

在linux云服务器下配置GoLang环境

在.bashrc添加对应指令

export GOROOT=/usr/local/go

export GOPATH=$HOME/GoLang

export GOBIN=$GOPATH/bin

export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

在linux云服务器下配置GoLang环境

你如果按照上面步骤只需要改下第二条就可以,保存退出

运行:source .bashrc

在linux云服务器下配置GoLang环境

查看go版本信息:go version

在linux云服务器下配置GoLang环境

6、现在就去刚刚配置的GOPATH文件夹里写go就可以了

vim main.go

package main

func main() {

println("Hello world")

}

在linux云服务器下配置GoLang环境

go run main.go

在linux云服务器下配置GoLang环境

至此第一个go程序编写完成。


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Letting Go of the Words

Letting Go of the Words

Janice (Ginny) Redish / Morgan Kaufmann / 2007-06-11 / USD 49.95

"Redish has done her homework and created a thorough overview of the issues in writing for the Web. Ironically, I must recommend that you read her every word so that you can find out why your customer......一起来看看 《Letting Go of the Words》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具