安装
下载 http://golangtc.com/download
安装 https://golang.org/doc/install?download=go1.8.3.darwin-amd64.pkg //osx
环境变量 $vi ~/.zshrc
export GOROOT=/Users/lucifer/Documents/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=/var/www
export PATH=$PATH:$GOPATH/bin
$source .zshrc
查看版本 $go version
查看位置 $which go
部署监控
框架
gin http://shanshanpt.github.io/2016/05/03/go-gin.html
IDEGogland https://www.jetbrains.com/go/
一般结构
//当前程序的包名
package main //一个可执行程序有且仅有一个main包
//导入其他的包
import . "fmt"
//常量定义
const PI = 3.14
//全局变量
var name = "hello"
//一般类型
type newType int
//结构声明
type newStruct struct {}
//接口声明
type newInterface interface {}
//main 函数只能在main包,main包需要main函数作为入口,不能有返回值
func main() {
fmt.Println("hello world!")
}
GO知识图谱
https://www.processon.com/view/link/5a9ba4c8e4b0a9d22eb3bdf0