get

  • 自动获取所有依赖

    go get .
    

build

usage: go build [-o output] [-i] [build flags] [packages]

编译指定包,以及其依赖

  • 如果是main包,则在当前目录下生成一个可执行文件

run

usage: go run [build flags] [-exec xprog] gofiles... [arguments...]

编译并运行main

  • 如果main包是由多个文件构成,则需要都指定!

test

usage: go test [-c] [-i] [build and test flags] [packages] [flags for test binary]

自动测试指定包

  • 默认情况,会编译当前目录包以及相应测试,并运行测试

参考

  1. https://github.com/astaxie/build-web-application-with-golang/blob/master/zh/01.3.md
  2. http://stackoverflow.com/questions/16935965/how-to-run-test-cases-in-a-specified-file
  3. http://stackoverflow.com/questions/19998250/proper-package-naming-for-testing-in-go-lang

留言

2016-05-12