vgo integration support

Package management has long been a topic of interest for many people in the Go community. A few months ago, the Go team put forward a new tool, based on the learnings from dep and other package managers. This tool is called vgo, and it’s backed by a new dependency solving algorithm called Minimal Version Selection, or MVS. All of this is described in great detail in Russ Cox’s blog post series.

Given the importance of this tool, it’s easy to see how the request to integrate it with the IDE quickly became one of the most voted features.

Today we are happy to announce the first version this integration is available as a plugin for GoLand 2018.1.2+. This feature will be integrated by default in the upcoming 2018.2 release.

Before you head over to Settings | Plugins | Install JetBrains plugin… and download the vgo support plugin, let’s see what it can do.

To create a project using vgo, you need to select the vgo type in the New Project dialog and then make sure that the IDE detected the vgo location correctly, after that, a new project will be created with the boilerplate go.mod file being created for it.

vgo - create new project

Now, let’s create a simple web server which will have a dependency. To do so, we’ll use the popular gorilla/mux package, and the following code:

The IDE will notice that there is no gorilla/mux currently defined in the go.mod file and it will suggest running the required vgo operation to update your dependencies list.

vgo - add new dependency

Similarly, if you remove a dependency from the go.mod file, the IDE will automatically remove the dependency from the list of available libraries, all seamlessly integrated into the workflow.

vgo - remove dependency

This is an early release of the plugin that we want to share with you. As such, it does have a few of issues of its own, not related to vgo itself.
Perhaps the one that you will first notice is that the IDE won’t allow you to use the vgo list quick fix if the package is already present in the GOPATH. This is a known limitation, and the recommendation is to set your GOPATH to point to somewhere else in the system, vgo still needs it to download and store the package cache. Another way to solve this is to remove the package from your GOPATH, but you will need to also invalidate the IDE cache. Please watch GO-5701 for updates on this issue.
The second issue is that currently the go.mod functionality is minimal, but we have plans to change this, GO-5691.
Another issue is that the “replace” syntax is currently not recognized by the IDE so forks or other sources for the packages will not work, see GO-5702 for more information.

And that’s it for now. Keep in mind that currently vgo is in very early stages and you are likely to encounter some rough edges. If you do so, please report them to us so we can address them or inform the Go team about them.

Please let us know in the comments below or on our issue tracker if you have any suggestions or feedback, or what would you like to see next. And remember, the 2018.2 EAP is right around the corner with a lot of new things to come.

About Florin Pățan

Developer Advocate at JetBrains
This entry was posted in New Features, Tutorial. Bookmark the permalink.

4 Responses to vgo integration support

  1. Andy says:

    Hi! How to change DEP project to VGO project?

  2. JtL says:

    Andy, what I did for one of my test projects, was to disable Dep and enable Vgo from IDE settings (checkbox and specify path to the Vgo).

    Then running the project lead to VGO error described at https://github.com/golang/go/issues/25110 (i.e. yet not recognized Gopkg.lock file).

    So, I had to remove that file (which might not what you like to do).

    Next error, I’ve got was about missing go.mod file. I’ve created one with single line inside:

    module domain.com/path

    Next, running the project was successful. The go.mod was filled with lines like this:

    require github.com/pkg/errors v0.8.0

    Hope that helps

Leave a Reply

Your email address will not be published. Required fields are marked *