Golang not working as documented




To work with Go’s expected directory structure, a symlink is placed to your project’s directory at /home/ubuntu/.go_project/src/github.com/<USER>/<REPO_NAME> (this happens at dependencies stage, unless that section is overridden).

I have no overriding in the dependencies phase. In fact, I don’t have any settings at all for the dependencies phase, and it doesn’t seem to perform a go get & go build as documented either.
When I ssh into the machine it doesn’t have a .go_project folder at all. ~/.go_workspace does exist though…


I’m not sure if this was you that opened this Pull Request but we’re aware and I’ll be looking into this. I’m not sure if anything changed or not but I’ll make sure the Go Doc is accurate.


Which image are you building on? I ran a test project on Ubuntu 14.04 and I see .go_project.


also building on Ubuntu 14.04
what’s the test project look like? is there a circle.yml file I can compare? a build result I can review?


I used CircleCI’s Inference commands, a.k.a didn’t override anything: https://circleci.com/gh/felicianotech/cci-testing-pub/380

SSHing into the build shows me both directories that the doc lists.


I took out the mongo stuff and tried a similar yaml file:

    - echo "Hi"

    - echo $PATH
    - go version
    - echo $GOPATH
    - ls -lah ~/
    - ls -lah /home
    - ps aux

during execution, in the dependencies phase, the only task that was run was the echo. There was no Setting up Go environment or any other go commands.

If there’s no main.go file directly in the parent level of the repo, how does CircleCI decide that it’s a golang project?


Thanks for the follow up. So, I took a look at it looks like for CircleCI’s inference to pick up a Go project, it checks for the existence of a least one .go in the root of the project. It doesn’t necessarily have to be main.go. From here I’d suggest two options:

  1. Place a .go file in the root, could be anything, hopefully something useful.
  2. Copy the commands from the Go doc and place them in the override sections.

I hope that helps.


Ok, option #1 (adding an empty .go file in the root) does trigger the project and setup the GOPATH correctly.

Option #2, is why I created this and titled it “Golang not working as documented”. The Setting up Go environment step during the dependencies phase is a black box and the little bit of info in the documentation doesn’t indicate what is needed for overriding.


since my projects needs to override the dependencies stage (and modify the go get), the other aspects of this black box need more definition.

The circle.yml equivalent of CircleCI's Inference is the following:

    # './...' is a relative pattern which means all subdirectories
    - go get -t -d -v ./...
    - go build -v

but then later in the doc it states,

a symlink is placed to your project's directory at /home/ubuntu/.go_project/src/github.com/<USER>/<REPO_NAME> (this happens at dependencies stage, unless that section is overridden).

that would imply, what exactly??? something like this:

    - ln -s . ${HOME}/.go_project/src/github.com/<USER>/<REPO_NAME>
    - go get -t -d -v ./...
    - go build -v


How does this look? https://github.com/circleci/circleci-docs/pull/651