使用
0.run build install 可以看这篇,感觉写得特别好
https://studygolang.com/articles/10572
1.go env
2.go run
和 go build
只要设置好$GOPATH
就可以使用
go run main.go
go run src/main.go # 相对路径课也可以
在src
内,go build
不用加文件名
go build
只要设置好$GOPATH
就可以使用
go build # 在 src 内,go build不用加文件名
go build main.go
go build src/main.go # 相对路径课也可以
4.install
同build
,但是会吧生成的文件放入pkg或者bin文件夹中
5.test
go test -v packagename
go test -v filename1,filename2,filename3
-v
显示测试的详细信息
测试
压力测试参考:
https://blog.csdn.net/code_segment/article/details/77507491
闭包和flag.parse()
:
http://blog.studygolang.com/2017/10/how-to-test-with-go/
go build –ldflags
go build默认情况下是有 调试信息的,可以直接gdb调试
想要去掉调试信息,需要额外加参数,参考
https://studygolang.com/articles/7496
go build -ldflags "-w -s" ./hello.go