Setting up a golang environment using reactive brains

I installed golang development envionemnt using the idea (13.1 community edition). It seems the SDK is recognized. However, I could not create the GO file by right-clicking "Create" in the source folder. (The "go" element is gray) Currently, I need to manually set the file extension to ".go" and edit the file, but autocomplete is fine. This only exists on my Mac (with version 10.9.4). I set the GOPATH directory access mode to 777, but still does not work. This works fine on windows7. So what should I do? enter image description here

This is what the windows look like. 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 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 here's what it looks like in the / Users / Tom / Go directory enter image description here

Thanks to VonC, however this will not work. I do not know the reason. This is the envionment setting using GOCODE enter image description here These are a few steps! step1

step 2

step3

step4

step5

this is envionment seting

By the way, I noticed that there is a difference with the poppy and windows when creating a new Go Project at this stage the Windows platform will show the "sdk project", but the mac will not. mac and windows not exactly at this step

+6
source share
2 answers

Make sure your IntelliJ project references the correct path within the GOPATH .
On the plugin page:

If you have only one directory in GOPATH, and you create a project inside this path when working with packages included in the project, you should still specify the whole import path for them, and not the relative one. Example:

  • GOPATH : / home / florin / go
    The correct way to set up a project called demogo is: /home/florin/go/src/github.com/dlsniper/demogo/
  • new package: /home/florin/go/src/github.com/dlsniper/demogo/newpack
  • Correct import instruction: github.com/dlsniper/demogo/newpack not newpack

Also make sure you have the latest version of the plugin installed, as issue 756 indicates that IntelliJ IDEA 13 is not creating the structure project directory on Mac OS X.


Finally, check if IDEA GOROOT and GOPATH :
See the " Fix Missing Environment Paths (Mac) " page.


OP python adds in the comments :

  • If I create a new Go project, this new feature is disabled.
  • If I create a new Java command-line application, then I could right-click and add a new Go file .
+2
source

Right-click either the top-level project or the src directory, and then go to Mark Directory As> Sources Root. After that, you can access the included Go context menus.

+1
source

Source: https://habr.com/ru/post/974630/


All Articles