英文:
How to make PyCharm work with the Go plugin?
问题
我正在使用PyCharm 3.1.1,并且已经安装了IntelliJ Idea的Go插件。我执行了export GOROOT=$(go env GOROOT)
命令,以防止PyCharm报错缺少GOROOT
环境变量。
现在我能够创建一个示例项目,但是运行命令报错:
> Error running untitled1.go: No Go Sdk defined for this project
在其他网站上,我找到了一些解决方法:
> 转到文件 -> 项目结构
,通过点击+
按钮并选择/usr/lib/go/
文件夹来配置Go SDK。
但是我没有文件 -> 项目结构
菜单项。
如何让PyCharm与Go插件配合工作?
英文:
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?
答案1
得分: 3
你可以通过使用外部工具来实现大部分功能。在下一个版本的插件中,无法替换“运行”按钮,详见问题#728。
设置外部工具的方法如下:进入PyCharm -> 首选项(command+,) -> 工具 -> 外部工具 -> +
填写表单:
点击确定。然后可以在菜单中使用它:
英文:
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:
答案2
得分: 2
你现在可以使用2016.1或更高版本来实现。我将提供一个完整的指南,所以前面的步骤对你来说不相关。另外,我是在MacOS上编写的,所以一些名称可能会有所不同。请按照以下步骤操作:
-
进入"Preferences(首选项)-> Plugins(插件)-> Browse Repositories(浏览存储库)-> Manage repositories(管理存储库)",然后插入
https://plugins.jetbrains.com/plugins/alpha/5047
,这是该存储库背后的插件(由IntelliJ维护)。安装该插件。 -
安装完插件后,创建一个
.go
文件。当你打开它时,会弹出一个提示窗口,显示"go project sdk is not defined"。点击它,并选择你的/usr/local/go
路径。
以下是一些有用的链接:
英文:
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:
答案3
得分: 1
请使用来自Github发布的最新版本 https://github.com/go-lang-plugin-org/go-lang-idea-plugin/releases。它支持PyCharm 4.0.5+。
英文:
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+.
答案4
得分: 0
如果你是IntelliJ的粉丝,你可以使用goland编辑器来编辑和运行Go代码(注意,这不是一个添加到PyCharm的Go插件,而是一个不同的编辑器)。
在Ubuntu上安装:
sudo snap install goland --classic
,或者访问他们的网站https://www.jetbrains.com/help/go/install-and-set-up-product.html
英文:
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
答案5
得分: -3
如果你正在使用OS X操作系统,你需要使用launchctl setenv
命令来设置GOROOT
环境变量,以便它在整个系统范围内可用,包括通过GUI启动应用程序。
launchctl setenv GOROOT $(go env GOROOT)
要检查是否设置成功,请运行以下命令:
launchctl getenv GOROOT
如果要在重新启动后保持数值不变,你需要编辑(或创建)/etc/launchd.conf
文件:
setenv GOROOT [path]
有关此文件格式的更多信息,请参见此答案。请注意,在launchd.conf
中无法调用$(go env GOROOT)
。
英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论