I am using PyCharm 3.1.1 and I have installed the Go plugin for IntelliJ Idea. I did export GOROOT=$(go env GOROOT)
to prevent PyCharm from complaining about missing GOROOT
environment variable.
Now I was able to create a sample project, but the run command complains:
Error running untitled1.go: No Go Sdk defined for this project
On other sites I found that I should do something like:
Go to the
File -> Project Structure
and configure Go SDK by clicking+
button and selecting/usr/lib/go/
folder.
But I don't have File -> Project Structure
menu item.
How to make PyCharm work with the Go plugin?
If you're running on OS X, you'll have to use the launchctl setenv
command to set the GOROOT
environment variable, so it's available system wide, which includes launching applications via the GUI
launchctl setenv GOROOT $(go env GOROOT)
To check it's set
launchctl getenv GOROOT
For the values to persist across reboots, you'll need to edit (or create) /etc/launchd.conf
:
setenv GOROOT [path]
See this answer for more information of the format of this file. Note that you won't be able to call $(go env GOROOT) within launchd.conf
You can get most of the way there with External Tools. There is no way to replace the 'Run' button until the next version of the plug-in, per Issue #728.
To set up your external tools, go to PyCharm -> Preferences (command+,) -> Tools -> External Tools -> +
Fill in the form:
Hit OK. Use it from the menus:
Please use the latest release from Github releases https://github.com/go-lang-plugin-org/go-lang-idea-plugin/releases. It supports PyCharm 4.0.5+.
You can achieve it now with a Version 2016.1 or higher. I will give a complete guide, so the first steps would not be relevant for you. Also I write it using MacOS, so some names might be different. Go to
Preferences -> Plugins -> Browse Repositories -> Manage repositories
and insert https://plugins.jetbrains.com/plugins/alpha/5047
which is the plugin behind this repo (maintained by IntelliJ). Install that plugin.
After plugin is installed, create a .go
file. When you open it you will see a popup go project sdk is not defined
. Click on it and select your /usr/local/go
path.
A couple of helpful links:
If you are an IntelliJ fan, you can edit and run Go using goland editor (Notice, this is not a Go plugin added to PyCharm but a different editor).
For installation on Ubontu: sudo snap install goland --classic
, or visit there website https://www.jetbrains.com/help/go/install-and-set-up-product.html