golang
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
安装
下载地址
https://golang.org/dl/ , 选择合适的版本
wget https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
tar zxvf go1.9.2.linux-amd64.tar.gz
mv go /usr/local/
配置环境变量
vi ~/.bashrc
或者 vi /etc/profile
,然后 source ~/.bashrc
export GOROOT='/usr/local/go'
export GOPATH='/www/go'
export GOBIN=$GOPATH/bin
export PATH=$PATH:${GOROOT}/bin:${GOBIN}
查看版本信息
[root@localhost ~]# go version
go version go1.9.2 linux/amd64
目录结构
Golang项目目录下一般有如下目录:
├── README.md ├── bin 编译后生成的可执行文件 │ ├── bee │ ├── main ├── pkg 编译后生成的文件 │ ├── darwin_amd64 │ └── linux_amd64 └── src 存放源代码 ├── github.com └── main.com
常用命令
启动
go run xxx.go
常用命令
go build compile packages and dependencies go clean remove object files go doc show documentation for package or symbol go env print Go environment information go bug start a bug report go fix run go tool fix on packages go fmt run gofmt on package sources go generate generate Go files by processing source go get download and install packages and dependencies go install compile and install packages and dependencies go list list packages go run compile and run Go program go test test packages go tool run specified go tool go version print Go version go vet run go tool vet on packages
IDE
- liteide https://github.com/visualfc/liteide
- goland https://www.jetbrains.com/go/
http server
// 处理输出
func handler(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "hello,world")
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":9001", nil)
}
参见
参考网址
- 官网 https://golang.org
- awesome-go https://awesome-go.com/
- beego go框架 https://github.com/astaxie/beego
- 知乎上关于GO的讨论 https://www.zhihu.com/question/30461290
- 菜鸟网络Go语言教程 http://www.runoob.com/go/go-tutorial.html
- GitHub上优秀的Go开源项目 http://www.flysnow.org/2016/12/27/golang-hot-project-in-github.html
- GO语言、DOCKER 和新技术 https://coolshell.cn/articles/18190.html