本文轉自http://studygolang.com/articles/2325
idea14 和go1.4不兼容,一直報這樣一個錯Argument for @NotNull parameter 'virtualFile' of com/intellij/openapi/projectRoots/impl/ProjectRootContainerImpl.addRoot must not be null
解決辦法:
google-go-lang-idea-plugin 插件雖然好,但是官方的編譯版總是更新很慢,所以需要自己編譯,問了老外才知道怎麼編譯,編譯方法如下:
I opened this project in IDEA Community 13 (or whatever the latest EAP is), then choose the SDK as the program folder (C:\Program Files\JetBrains\Intellik IDEA Community Edition) and then went to Build -> Prepare for Deployment. It'll save a jar file in the location that popups up and then you can install that in an IDEA IDE.
具體的過程,我截圖如下:
intellijIDEA的首頁放的是穩定版,而我們要找到測試版,直接點如下鏈接就能下載測試版:
http://www.jetbrains.com/idea/nextversion/index.html
如下圖:
下載安裝完成後,點擊help菜單更新,如下圖:
然後下載 idea的 golang插件源碼:
https://github.com/mtoader/google-go-lang-idea-plugin
如下圖:
解壓到任意目錄,比如c:\idea_golang
然後用idea打開這個目錄,即點擊菜單 File》Open
然後再設置一下環境:
分別指定:
- jdk的目錄(需要去java首頁下載)
- idea的安裝目錄
- go語言的安裝目錄(需要去golang的首頁下載)
如下圖:
設置完SDKs之後,還要在Modules頁面重新指定一下idea的安裝目錄,看圖:
最後可以Ctrl+Shift+F9編譯試試,如果彈出的信息都是警告(warning)信息而沒有錯誤信息(error),那就說明沒問題了。
接下來就可以像老外說的那樣,點擊菜單:
Build -> Prepare for Deployment
會在項目目錄生成一個jar文件。
這個就是編譯好的插件了。
安裝這個插件的方法是:
File》Settings》Plugins》Install plugin from disk