Set different GOPATH for each Sublime Text project

651 views
Skip to first unread message

Tad Vizbaras

unread,
Sep 25, 2014, 8:33:04 AM9/25/14
to golan...@googlegroups.com
This is a bit off topic, but it is huge time saver if you use Sublime Text + GoSublime combo for development.

One important point if you use different GOPATH for different projects: you can setup GoSublime to execute build once you save changes into *.go file. 
That is like Project Build on Save with specific GOPATH.

This seemingly simple feature saves time if you use multiple GOPATH setups.
If you use single GOPATH for all your projects skip #1.

There is how to do it:

1. Open your project file as text and add lines. This should be done for each project:
{
    "GoSublime":
    {
        "env":
        {
            "GOPATH": "$HOME/your_project_dir"
        }
    }
}

2. Edit GoSublime.sublime-settings file :
{
"on_save": [    {"cmd": "gs9o_open", "args": {
"run": ["go build"],
"focus_view": false}
    }
],


meta keule

unread,
Sep 25, 2014, 8:37:40 PM9/25/14
to golan...@googlegroups.com
Thanks for sharing!

I want to used it the following way

{
    "GoSublime":
    {
        "env":
        {
            "GOPATH": "$HOME/shared_gopath:$HOME/your_project_dir"
        }
    }
}

but it does not seem to work (although the go tools support that notion).
any hints?

meta keule

unread,
Sep 25, 2014, 9:06:19 PM9/25/14
to golan...@googlegroups.com
now got it, must be

{ "settings:"

{
    "GoSublime":
    {
        "env":
        {
            "GOPATH": "$HOME/shared_gopath:$HOME/your_project_dir"
        }
    }
}
}

sorry for the noise...


Am Donnerstag, 25. September 2014 14:33:04 UTC+2 schrieb Tad Vizbaras:

Camilo Aguilar

unread,
Sep 27, 2014, 10:58:51 PM9/27/14
to meta keule, golan...@googlegroups.com
Nice tip! FWIW, you can also use http://direnv.net/ for a similar purpose.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Camilo Aguilar
Software Engineer


Reply all
Reply to author
Forward
0 new messages