title: Fake go environment from a shell script
body: <p>I am using ultimate with goland plugin and <code>dep</code>. I used to work outside <code>GOPATH</code> as well. Usually without idea I am using a shell script and <code>Makefile</code> to build project and was so far happy with it. Idea with <code>dep</code> integration of course forces me to work inside <code>GOPATH/src</code>. Is there any way to configure that IDE to run a shell script which will fake project environment, set <code>GOPATH</code>, <code>GOBIN</code> and make <code>dep</code> happy and get rid of <code>... is not within a known GOPATH/src</code> and "missing" imports.</p>
  
  <p>I have tried to run it via <code>./build/env.sh idea .</code> but still getting missing imports and <code>... is not within a known GOPATH/src</code>. Tried to play with project settings as well, seems nothing can satisfy that <code>gep</code>.</p>
  
  <p>env.sh</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/bin/sh
  
  set -e
  
  if [ ! -f "build/env.sh" ]; then
      echo "$0 must be run from the root of the repository."
      exit 2
  fi
  
  project="proj"
  repositoryRoot="domain.com/username"
  
  # Create fake Go workspace if it doesn't exist yet.
  workspace="$PWD/build/_workspace"
  root="$PWD"
  dir="$workspace/src/$repositoryRoot"
  if [ ! -L "$dir/$project" ]; then
      mkdir -p "$dir"
      cd "$dir"
      ln -s ../../../../../. $project
      cd "$root"
  fi
  
  # Set up the environment to use the workspace.
  # Also add Godeps workspace so we build using canned dependencies.
  GOPATH="$workspace"
  GOBIN="$PWD/build/bin"
  
  # Run the command inside the workspace.
  cd "$dir/$project"
  PWD="$dir/$project"
  
  # Launch the arguments with the configured environment.
  exec "$@"
  </code></pre>
  
  <p>Makefile</p>
  
  <pre><code>.PHONY: all test clean
  
  GOBIN = build/bin
  
  all:
      build/env.sh go get github.com/golang/dep/cmd/dep
      build/env.sh $(GOBIN)/dep ensure
      build/env.sh go build -v -o $(GOBIN)/proj
  </code></pre>