GOPATH is set to multiple directories


#1

GOPATH is currently set to /home/ubuntu/.go_workspace:/usr/local/go_workspace

This makes it impossible to reference tools in $GOPATH/bin

/usr/local/go_workspace does not actually exist either.

Can GOPATH be limited to a single directory?


#2

Won’t be replying with a solution. But I can offer some insights.

Circle uses a funky Go setup. They keep the checked out branch separate (~/.go_project) from all dependencies (~/.go_workspace). And I’m not sure what the /usr/local/go_workspace is used for.

The reason for this separation is probably because of caching. Which is actually a problem I have (by default they do go get, without -u). So whenever a non-vendored dependency changes, I need to “build without cache”.

GOPATH is actually a PATH directive, so they are conform specification. However not all tools or conventions work well with that.

I’m hoping CircleCI steps up it’s game to better support Go!


#3

We ended up just replacing GOPATH variable and setting up as follows:

---

machine:
  environment:
    GOPATH: $HOME/.go_project
    PATH: $PATH:$HOME/.go_workspace/bin

dependencies:
  pre:
    - mkdir -p $HOME/download
    - test -e $HOME/download/go1.7.1.linux-amd64.tar.gz || curl -o $HOME/download/go1.7.1.linux-amd64.tar.gz https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz
    - sudo rm -rf /usr/local/go
    - sudo tar -C /usr/local -xzf $HOME/download/go1.7.1.linux-amd64.tar.gz
  override:
      - echo 'export GOPATH=$HOME/.go_project' >> ~/.circlerc
      - cd $HOME/.go_project/src/github.com/osgcorp/$CIRCLE_PROJECT_REPONAME && go get -t -d -v ./...

...

#4

This does not work anymore. It would be really good if CircleCI would simply use one path, which is the recommended approach anyway.


#5

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.