Creating a symbolic link to a Go project folder

657 views
Skip to first unread message

ran...@sturgis.io

unread,
Jul 23, 2016, 11:44:29 PM7/23/16
to golang-nuts
Hello!

Is the following a bad practice? Can it cause issues with the Go tool set?
  • my GOPATH is set to $HOME
  • I have Go code in a git repo named ~/src/github.com/my-user/my-project
  • I have a project folder with notes, todo's and other reference files named ~/gtd/projects/my-project
  • I created a symbolic link from ~/src/github.com/my-user/my-project to ~/gtd/projects/my-project/repo
I noticed that when I cd into the linked repo, my current working directory is still under ~/gtd and not ~/src, but go build and go install appear to work.

Randall

sturgis.io, inc.

Dave Cheney

unread,
Jul 24, 2016, 12:12:52 AM7/24/16
to golang-nuts, ran...@sturgis.io
The Go tool does not work well with symlinks because they can break the assumption that the source of a package has one canonical import path. 

Various parts of the Go tool apply this rule differently, so you might get away with it, but please be aware that this is not something that the Go tool encourages and you'll have a more enjoyable experience if you place your source code under GOPATH without symlinks.
Reply all
Reply to author
Forward
0 new messages