go 简介与安装
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
热门日志
分类
- Django(4)
- ssdb(1)
- Mac(7)
- C(1)
- memcache(1)
- Python(32)
- Vim(8)
- sed(2)
- ansible(3)
- awk(4)
- shell(3)
- about(1)
- git(9)
- bat(4)
- svn(0)
- docker(1)
- Tornado(1)
- go(2)
- 架构(18)
- Vue(1)
- game(2)
- Html(6)
- Java(8)
- Mysql(37)
- Ajax(2)
- Jsp(1)
- Struts(8)
- Linux(72)
- JavaScript(39)
- Staruml(0)
- Mouth(1)
- Php(102)
- Windows(8)
- Message(48)
- Lua(10)
- Compute(1)
- Redis(7)
- Nginx(12)
- Jquery(1)
- Apache(1)
- cocos2d-x(8)