(golang) support for projects where GOPATH contains a symbolic link

Answered

We have a project which uses golang (but not exclusively) and so it has a directory structure that does not follow the GOPATH conventions.

In order to build the golang component(s) we use symbolic links that allow us to configure a GOPATH that matches the convention <GOPATH>/src/<component>.

Building works, but I cannot configure IDEA to use a GOPATH that uses the symbolic link and so it does not resolve imports, making it hard to
use IDEA as an IDE. For various reasons we would like to keep our current project layout the way it is. Note the project uses vendoring so
all the imports are actually under the root of the golang component

So, I've got a couple of questions:
1. Is there a way to get IDEA to follow symbolic links when resolving imports?
2. Is there a way to get IDEA to use a global GOPATH defined in the environment (but which contains a symbolic link to the project?)

What I've tried so far (for a project called doodle for example):

1. symbolic link configured inside project directory like so:
    <project root>: /home/user/work/doodle

     <project root>
             +--- <gopath dir>
                +--- src
                    +--- <sym link to project root>

     GOPATH=/home/user/work/doogle/gopath

2. symbolic link from externally defined GOPATH and project dir somewhere in /home/user/work/:

    GOPATH=/home/<user>/go

    and a symlink: ${GOPATH}/src/doodle --> /home/user/work/doodle

 

Note 1 above is a configuration that works with our build tool (make)

 

Cheers,

 

B

0

Please sign in to leave a comment.