本人也是今天正式开始步入Golang语言的学习,希望大家一起共同学习。
官网地址:https://studygolang.com/dl
系统要求
Operating system | Architectures | Notes |
---|---|---|
FreeBSD 10.3 or later | amd64, 386 | Debian GNU/kFreeBSD not supported |
Linux 2.6.23 or later with glibc | amd64, 386, arm, arm64, s390x, ppc64le | CentOS/RHEL 5.x not supported. Install from source for other libc. |
macOS 10.10 or later | amd64 | use the clang or gcc† that comes with Xcode‡ for cgo support |
Windows 7, Server 2008R2 or later | amd64, 386 | use MinGW gcc†. No need for cygwin or msys. |
安装GO工具
[root@devlop package]# wget https://studygolang.com/dl/golang/go1.12.7.linux-amd64.tar.gz
[root@devlop package]# tar -zxvf go1.12.7.linux-amd64.tar.gz -C /usr/local/
[root@devlop package]# cd /usr/local/go/
[root@devlop go]# ls
api AUTHORS bin CONTRIBUTING.md CONTRIBUTORS doc favicon.ico lib LICENSE misc PATENTS pkg README.md robots.txt src test VERSION
为GO设置全局环境变量。
[root@devlop go]# vim /etc/profile <!--在最后添加一行-->
export PATH=$PATH:/usr/local/go/bin
[root@devlop go]# source /etc/profile
[root@devlop ~]# go version
go version go1.12.7 linux/amd64
新建test项目测试
[root@devlop ~]# mkdir test
[root@devlop ~]# vim test/test.go
package main
import "fmt"
func main() {
fmt.Println("Welcome Golang")
}
保存退出并编译test.go文件
[root@devlop ~]# cd test/
[root@devlop test]# go build test.go
编译后会在项目文件夹下生成test可执行文件,并运行该文件
两种方式任选其一:
好了到这里我们我安装结束了。欢迎一起学习Golang ! ! !
有疑问加站长微信联系(非本文作者)