duanan1946 2014-09-01 07:43
浏览 318
已采纳

使用jetbrains设置golang环境

I have setup an golang developing envionemnt using idea (13.1 community edition). It seems the SDK is recognized. However, I could not create a GO file by right click the "New" under the source folder. (The item of "go" is grayed) Currently I have to manually set the file extension to ".go" and edit the file, but autocomplete is OK. This only exist on my Mac(with version 10.9.4) I have set the GOPATH directory access mode to 777 but still not work. This works fine on windows7. So what should I do ?enter image description here

This is what it looks like in windows enter image description here

Thanks VonC, I already tried the /Users/Tom/go setting, this doesn't work and I switch to this root path.
here's my previous setting

 macbook:home root# go env
GOARCH="amd64"
GOBIN=""
GOCHAR="6"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mac/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"

And this is what is look like in the /Users/Tom/Goenter image description here

Thanks VonC, however, this doesn't work. I am not sure what's the reason. This is the envionment setting using GOCODE enter image description here This is several steps! step1

step 2

step3

step4

step5

this is envionment seting

By the way, I noticed that there are a difference from mac and windows when creating a new Go Project at this step, the windows platform will show a "project sdk" while mac won't. mac and windows not exactly at this step

  • 写回答

2条回答 默认 最新

  • doudan5136 2014-09-01 07:47
    关注

    Make sure your IntelliJ project reference the right path within GOPATH.
    From the plugin page:

    If you have only one directory in the GOPATH and you are creating a project inside that path when you are working with packages that are part of the project you must still specify the whole import path for them, not the relative one. Example:

    • GOPATH is: /home/florin/go
      the correct way to setup a project called demogo is: /home/florin/go/src/github.com/dlsniper/demogo/
    • new package is: /home/florin/go/src/github.com/dlsniper/demogo/newpack
    • the correct import statement is: github.com/dlsniper/demogo/newpack not newpack

    Also make sure you have the latest version of the plugin, as issue 756 illustrates that IntelliJ IDEA 13 doesn't create the project directory structure on Mac OS X.


    Finally, check if IDEA has correctly detected GOROOT and GOPATH:
    See the page "Fix missing environment paths (Mac)".


    The OP python adds in the comments:

    • If I have create a new Go project, this new feature is disabled.
    • If I create a new Java Command line App, then I could right click and add new Go file.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘