I’ve been attempting to get a Go lang project (1.5.1) going in CircleCI and then do continuous deployment to Heroku. We are using the vendor experiment and have the packages properly vendored.
I’ve had some assistance in getting 1.5.1 installed but am running in to trouble attempting to run the tests.
This is a sample of the errors:
cd ~/.go_workspace; go test -v $(go list ./... | grep -v /vendor/) -race -p=1
src/github.com/onsi/gomega/ghttp/handlers.go:12:2: cannot find package "github.com/golang/protobuf/proto" in any of:
/usr/local/go/src/github.com/golang/protobuf/proto (from $GOROOT)
/home/ubuntu/.go_workspace/src/github.com/golang/protobuf/proto (from $GOPATH)
/usr/local/go_workspace/src/github.com/golang/protobuf/proto
src/github.com/stretchr/testify/mock/mock.go:12:2: cannot find package "github.com/stretchr/objx" in any of:
/usr/local/go/src/github.com/stretchr/objx (from $GOROOT)
/home/ubuntu/.go_workspace/src/github.com/stretchr/objx (from $GOPATH)
/usr/local/go_workspace/src/github.com/stretchr/objx
My circle.yml looks like this:
machine:
post:
- sudo rm -rf /usr/local/go
- if [ ! -e go1.5.linux-amd64.tar.gz ]; then curl -o go1.5.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz; fi
- sudo tar -C /usr/local -xzf go1.5.linux-amd64.tar.gz
dependencies:
cache_directories:
- ~/go1.5.linux-amd64.tar.gz
override:
- echo "Skipping defaults (go get)"
test:
override:
- cd ~/.go_workspace; go test -v $(go list ./... | grep -v /vendor/) -race -p=1
Note that I skip the “go get” because the packages are vendor and because it otherwise tries to get the project package itself.
Also the test command is overridden to facilitate the -p=1 option (to force main_test.go to run first to set up the database).
Finally here is my GoDeps.
{
"ImportPath": "hw-distribution",
"GoVersion": "go1.5.1",
"Packages": [
"hw-distribution",
"hw-distribution/brands",
"hw-distribution/models",
"hw-distribution/orders",
"hw-distribution/products",
"hw-distribution/shipments",
"hw-distribution/util",
"hw-distribution/webhooks"
],
"Deps": [
{
"ImportPath": "github.com/gin-gonic/gin",
"Comment": "v1.0rc1-136-gfd5d429",
"Rev": "fd5d4294a5d5223d55fc76d7840f4b0ad91647bb"
},
{
"ImportPath": "github.com/go-sql-driver/mysql",
"Comment": "v1.2-37-g8afc3be",
"Rev": "8afc3be42072f568b4868b4afe97bff228a1fb32"
},
{
"ImportPath": "github.com/jmoiron/sqlx",
"Comment": "sqlx-v1.1-42-g344b1e9",
"Rev": "344b1e96d6e410a093b7bce40287731a49e253f6"
},
{
"ImportPath": "github.com/manucorporat/sse",
"Rev": "fe6ea2c8e398672518ef204bf0fbd9af858d0e15"
},
{
"ImportPath": "github.com/mattn/go-colorable",
"Rev": "40e4aedc8fabf8c23e040057540867186712faa5"
},
{
"ImportPath": "github.com/stretchr/testify/assert",
"Comment": "v1.0-40-g7c2b1e5",
"Rev": "7c2b1e5640dcf2631213ca962d892bffa1e08860"
},
{
"ImportPath": "golang.org/x/net/context",
"Rev": "b026840ad5cb594d38a2b783be1b6644fe5325fb"
},
{
"ImportPath": "gopkg.in/bluesuncorp/validator.v5",
"Comment": "v5.11",
"Rev": "98121ac23ff3d764f525d18d8de944d150e3c0fe"
},
{
"ImportPath": "gopkg.in/bsm/ratelimit.v1",
"Rev": "bda20d5067a03094fc6762f7ead53027afac5f28"
},
{
"ImportPath": "gopkg.in/guregu/null.v2",
"Comment": "v2.1.1",
"Rev": "5bc3c32da7d04df1bcea52382b239d6dcf4e6ded"
},
{
"ImportPath": "gopkg.in/redis.v3",
"Comment": "v3.2.10",
"Rev": "eef3fd78ef0f78e8406339c27fd46c6af93f24ba"
}
]
}
I’m at a loss at this point where to proceed. There is not enough documentation about how the environment is set up for Go on the container.