LoginSignup
3
6

More than 5 years have passed since last update.

複数パッケージのGoプロジェクトのビルドとテスト方法

Last updated at Posted at 2016-05-18

Goのプログラミングパターンの記事では、gbの利用が勧められていたが、外部パッケージがなくても、ディレクトリ配下のすべてのプロジェクトをビルドとテストが実施できることがわかった。

export GOPATH=your_project_gopath
cd your_project_path
go build ./...

./...でディレクトリ配下の全てのパッケージを示すらしい。

テストも以下でできる

export GOPATH=your_project_gopath
cd your_project_path
go test -cover ./...

gbがWindows&msysで動かなかったり、カバレッジに未対応だったりしたので、このようにしている。

あと、プロジェクトごとにGOPATHを切り直し、プロジェクトが終わるとそれごと削除するようにすると、なかなか便利です。

参考: http://stackoverflow.com/questions/17913715/three-dots-directory-traversal-with-mv

3
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
6