CircleCI和Golang-无法导入AWS开发工具包

I'm not sure whether this is the right place to post such question.

I was trying to test my golang project on CircleCI. In the phase of dependencies, CI executed

go get -u github.com/aws/aws-sdk-go/...

And there occurred an error:

package github.com/aws/aws-sdk-go/...
    imports github.com/aws/aws-sdk-go/aws
    imports github.com/aws/aws-sdk-go/aws/awserr: /home/ubuntu/sprocket-analytics-data-pipeline-v2/src/go/src/github.com/aws/aws-sdk-go is from git@github.com:aws/aws-sdk-go, should be from https://github.com/aws/aws-sdk-go

The error was very long, and the code above is just a part of it.

So, I updated my circleci.yml to override the dependencies phase. The circleci.yml is like:

machine:
  timezone:
    Asia/Tokyo
  environment:
    GOPATH: /home/ubuntu/my-project/src/go
dependencies:
  override:
    - go get github.com/go-sql-driver/mysql
    - go get github.com/google/google-api-go-client/bigquery/v2
    - go get code.google.com/p/goauth2/oauth/jwt
    - go get golang.org/x/tools/cmd/cover
    - go get github.com/AlekSi/gocov-xml
    - go get github.com/jstemmer/go-junit-report
    - go get github.com/golang/mock/gomock
    - go get github.com/onsi/gomega
    - go get github.com/onsi/ginkgo/ginkgo
    - go get github.com/aws/aws-sdk-go/...
    - go get github.com/axw/gocov/...
test:
  pre:
    - go install path/to/the/package
  override:
    - go test /home/ubuntu/my-project/src/go/src/path/to/the/package

The go get github.com/aws/aws-sdk-go/... in my config worked fine.

However, after all the commands in my circleci.yml had been executed, go get -u github.com/aws/aws-sdk-go/... was executed anyway by the CI. And it failed again with the same error.

Here is the log from CircleCI:

enter image description here

Is there any walk-around for this? Or did I miss something, like configuring the address to get the go packages(according to the error messages)?

Thanks in advance!

Try adding the following to your circle.yml file. This should force an SSH checkout rather than a http one.

checkout:
  post:
    - git config --global url.ssh://git@github.com/.insteadOf https://github.com/

You should then be able to remove all of your dependency overrides.

CircleCI also has a nice feature where you can rebuild with an SSH connection. Try running the commands manually inside the container if you have problems with debugging.

Ok, I found a walk-around for this.

It seems that CircleCI is using go 1.4, which did not allow people to use git@github.com to make go get -u, unless you use go get -u -f. So I figured trying to use https to do the go get -u is the only way currently.

ref: issue #8850

And CircleCI has its own configuration on git in ~/.gitconfig to force git to use git@github.com instead of https:

[url "git@github.com:"]
        insteadOf = https://github.com/
[url "ssh://git@github.com/"]
        insteadOf = https://github.com/

If you access to the box of CircleCI via ssh, you can find this file.

ref

So, my way is:

Rename this file in the phase of dependencies-pre, and let dependencies phase finish, Then rename it back if you still need those configurations.

Now go get -u works fine no matter whether you add it in the circle.yml file or it is executed automatically by CircleCI.