Go 是一个开源的编程语言,它能让构造简单、可靠且高效的软件变得容易。
Go 语言特色
简洁、快速、安全
并行、有趣、开源
内存管理、v数组安全、编译迅速
Go 语言用途
Go 语言被设计成一门应用于搭载 Web 服务器,存储集群或类似用途的巨型中央服务器的系统编程语言。
对于高性能分布式系统领域而言,Go 语言无疑比大多数其它语言有着更高的开发效率。它提供了海量并行的支持,这对于游戏服务端的开发而言是再好不过了。
各种版本的下载地址:
https://golang.org/dl/
Go环境安装:
1、wget方式下载并解压
wget https://dl.google.com/go/go1.9.3.linux-amd64.tar.gz
sudo tar -xzf go1.9.3.linux-amd64.tar.gz -C /usr/local/lib
2、添加配置
echo 'export GOROOT=/usr/local/lib/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=$HOME/.go' | sudo tee -a /etc/profile.d/go.sh
# 让配置生效
sudo source /etc/profile.d/go.sh
3、检测环境是否成功
#go 
Go is a tool for managing Go source code.
Usage:
 go command [arguments]
The commands are:
 build       compile packages and dependencies
 clean       remove object files
 doc         show documentation for package or symbol
 env         print Go environment information
 bug         start a bug report
 fix         run go tool fix on packages
 fmt         run gofmt on package sources
 generate    generate Go files by processing source
 get         download and install packages and dependencies
 install     compile and install packages and dependencies
 list        list packages
 run         compile and run Go program
 test        test packages
 tool        run specified go tool
 version     print Go version
 vet         run go tool vet on packages
Use "go help [command]" for more information about a command.
Additional help topics:
 c           calling between Go and C
 buildmode   description of build modes
 filetype    file types
 gopath      GOPATH environment variable
 environment environment variables
 importpath  import path syntax
 packages    description of package lists
 testflag    description of testing flags
 testfunc    description of testing functions
Use "go help [topic]" for more information about that topic.
环境安装成功!!!
编写第一个go程序,helloWorld.go:
#cat > helloWorld.go <<EOF
package main
import "fmt"
func main() {
    fmt.Printf("hello, world\n")
}
EOF
运行此代码: go run helloWorld.go
# go run helloWorld.go 
hello, world
环境卸载:
unset GOBIN GOPATH GOROOT #环境变量删除
rm -rf /usr/local/go /etc/profile.d/go.sh
参考:
https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/01.1.md
https://golang.org/doc/install