読者です 読者をやめる 読者になる 読者になる

人権真骨頂

とくがたかいことでゆうめい

werckerでGoのsub packageがインポートできない時の対処法

github.com/foo/bar みたいなプロジェクトで, github.com/foo/bar/foobarimport したら以下のようなエラーが出た.

can't load package: package _/pipeline/source: cannot find package "_/pipeline/source" in any of:
    /usr/local/go/src/_/pipeline/source (from $GOROOT)
    /go/src/_/pipeline/source (from $GOPATH)
can't load package: package _/pipeline/source/controllers: cannot find package "_/pipeline/source/controllers" in any of:
    /usr/local/go/src/_/pipeline/source/controllers (from $GOROOT)
    /go/src/_/pipeline/source/controllers (from $GOPATH)
can't load package: package _/pipeline/source/models: cannot find package "_/pipeline/source/models" in any of:
    /usr/local/go/src/_/pipeline/source/models (from $GOROOT)
    /go/src/_/pipeline/source/models (from $GOPATH)

その時の wercker.yml .(deployとかserviceとか途中の省いても良いstepは省略している.)

box: golang
build:
  steps:

    - script:
        name: godep
        code: |
          go get github.com/tools/godep && godep restore

    - script:
        name: go test
        code: |
          go test -v $(go list ./... | grep -v /vendor/)

これは,stepsetup-go-workspace を加えてやると良い.で,こんな感じになる.

box: golang
build:
  steps:
    - setup-go-workspace

    - script:
        name: godep
        code: |
          cd $WERCKER_SOURCE_DIR
          echo `pwd`
          go get github.com/tools/godep && godep restore

    - script:
        name: go test
        code: |
          go test -v $(go list ./... | grep -v /vendor/)

これで動作するようになる,ハズ.