Golang学习系列第一天:安装golang

六眼飞鱼酱① 提交于 2020-10-04 05:11:48

 

0.  ssh连接linux(我用的centos7),略

1.  golang下载

由于Golang官网https://golang.org/国内无法直接访问,故可以到Go语言中文网下载:https://studygolang.com/dl,可根据自己的电脑操作系统下载对应的版本,我下载的是go1.14.4.linux-amd64.tar.gz最新(当前时间)安装包,不过也可以直接点击下面这个链接直接下载https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz,即

[root@master dgm]# wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz

2.  golang安装

     解压golang压缩文件

[root@master dgm]# tar -zxvf go1.14.4.linux-amd64.tar.gz 

配置环境变量,编辑/etc/profile文件,即vim  /etc/profile

追加以下内容:

golang配置

保存该配置文件

然后重载配置 source /etc/profile 使之生效

最后查看是否生效

go version

  go版本检查

3.  helloworld测试

新建hello.go文件

touch hello.go

然后编辑该hello.go文件,键入以下内容

package main

import "fmt"

func main() {
    fmt.Printf("hello,world!\n")
}

退出保存

然后在命令行执行go run hello.go,可以看到如下结果

 

 helloworld

参考:

  1. https://gomirrors.org/
  2. https://studygolang.com/dl
  3. CentOS7安装golang1.6环境  https://blog.51cto.com/11434894/2353293

  4. 你再也不用设置 GOROOT 了  https://zhuanlan.zhihu.com/p/93776289

  5. Golang 1.13: 解决国内 go get 无法下载的问题  https://www.sunzhongwei.com/problem-of-domestic-go-get-unable-to-download

  6. https://goproxy.io/zh/
  7. Golang Guide: A List of Top Golang Frameworks, IDEs, and Tools  https://dzone.com/articles/golang-guide-a-list-of-top-golang-frameworks-ides
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!