我使用IntelliJ IDEA作为golang IDE,并且系统环境已经设置了GOPATH,但是IDEA无法加载它 [英] I use IntelliJ IDEA as golang IDE, and system environment have already set GOPATH,But IDEA can't load it

查看:576
本文介绍了我使用IntelliJ IDEA作为golang IDE,并且系统环境已经设置了GOPATH,但是IDEA无法加载它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows中使用IntelliJ IDEA作为golang IDE,并且系统环境已经设置了GOPATH,但是IDEA无法加载$ GOPATH。

我使用去获取github.com/astaxie/beego ,这个软件包安装正确,但是在IDEA中可以't导入这个库。



我已经用这种方式在项目结构中添加了这个包:



和这个项目的选择Go sdk go1.1.1 windows / amd64like



如何设置GOPATH?

解决方案

更新(2017-10-22) h1>

根据新版Gogland(EAP 16)的发布记录,相应的 Go插件只能与IntelliJ IDEA Ultimate 一起使用上。这遵循了通过IntelliJ IDEA Ultimate插件提供对不同语言支持的模式,或者作为独立的IDE(如PyCharm,Webstorm,或者在这种情况下,Gogland)。

欲了解更多详情,请参阅相关博文
$ b

更新(2017-04-24)



作为最终解决OP问题的替代解决方案,我想推荐专门用于Go开发的新IDE,JetBrains Gogland。这个设置几乎毫不费力,但如果你遇到困难,那么已经提供了一些提示文档。

检查 Gogland ,可能适合你。 $ b

还有一个官方插件表示你可以在Gogland找到的所有东西。



如果您想知道这个新插件与旧版 go-lang-idea-plugin 有什么不同,请检查常见问题解答文章和解释。



原始答案



背景信息



在OS X Mavericks上,通过Macports安装Go。在IntelliJ IDEA中使用Go插件0.9.15。



问题



我想让IDE了解导入并为我在GOPATH中安装的任何软件包提供自动完成功能。 (我开始使用Revel创建应用程序,并且缺少自动完成...)



解决方案



这里是我做了什么:


  • 配置Go SDK(在菜单中:查看>打开库设置>平台设置> SDK)。

  • 打开要设置的Go SDK的Classpath选项卡。
  • 添加一个新项目,在$ GOPATH中选择'src'目录。

  • 点击'应用'或'确定'。

  • (不工作!?!?,抱怨,头痛...)

  • 在菜单中:File> Invalidate Caches / Restart ...

  • 点击'Invalidate and Restart'。



希望这可能就是您要找的!


I use IntelliJ IDEA as golang IDE in Windows , and system environment have already set GOPATH,but IDEA can't load $GOPATH.

I use go get github.com/astaxie/beego, this package is installed correctly, but in IDEA can't import this library.

I have added this package in project's structure in this way:

and this project's choice "Go sdk go1.1.1 windows/amd64 "like

how can I set GOPATH in idea?

解决方案

Update (2017-10-22)

According to the release notes of the new version of Gogland (EAP 16), the corresponding Go plugin can only be used with IntelliJ IDEA Ultimate from now on. This follows the pattern of providing support for different languages either via a plugin for IntelliJ IDEA Ultimate, or as a standalone IDE, such as PyCharm, Webstorm, or in this case, Gogland.

For more details see the related blog post.

Update (2017-04-24)

As an alternative solution that ultimately deals with the OP's problem, I would like to recommend the new IDE specifically for Go development, JetBrains Gogland. The setup is pretty much effortless, but in case you would have difficulties, there is already heplful documentation provided.

Check Gogland, might work for you.

There is also an official plugin that "has everything you could find in Gogland".

In case you are wondering what could be the difference between this new plugin, and the old go-lang-idea-plugin, check the FAQ article with the explanation.

Original answer

Background info

On OS X Mavericks, Go installed via Macports. Using Go plugin version 0.9.15 with IntelliJ IDEA.

Problem

I wanted to make the IDE understand the imports and provide autocomplete for any package I have installed in GOPATH. (I started creating an app using Revel and were missing the autocomplete...)

Solution

Here is what I did:

  • Configure the Go SDK (In menu: View > Open Library Settings > Platform Settings > SDKs).
  • Open the "Classpath" tab of the Go SDK you want to set up.
  • Add a new item, select the 'src' directory in your $GOPATH.
  • Click 'Apply' or 'OK'.
  • (not working!?!?, grumble, headache...)
  • In menu: File > Invalidate Caches / Restart...
  • Click 'Invalidate and Restart'.
  • WIN!

Hope this might be what you were looking for!

这篇关于我使用IntelliJ IDEA作为golang IDE,并且系统环境已经设置了GOPATH,但是IDEA无法加载它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆