GoLand IDE无法正确编译。 如何设置正确的路径?

I am trying to setup GoLand correctly to be able to use it with Go.

I'm trying to run the follow simple HelloWorld go project.

package HelloWorldProject


import "fmt"

func main(){
    fmt.Printf("Hello")

    fmt.Printf("1+1 = ", 1+1)

}

This is my console's results:

GOROOT=/usr/local/Cellar/go/1.10/libexec #gosetup
GOPATH=/Users/jeanmac/go #gosetup
/usr/local/Cellar/go/1.10/libexec/bin/go build -i -o /private/var/folders/r5/rfwd1cqd4kv8cmh5gh_qxpvm0000gn/T/___Hello /Users/jeanmac/go/src/github.com/jpere547/HelloWorldProject/Hello.go #gosetup

Compilation finished with exit code 0

I am on Mac OS and I installed Go using Brew.

Results of brew info go:

go: stable 1.10 (bottled), HEAD
Open source programming language to build simple/reliable/efficient software
https://golang.org
/usr/local/Cellar/go/1.10 (8,150 files, 336.9MB) *
  Poured from bottle on 2018-03-22 at 19:38:29
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/go.rb
==> Requirements
Required: macOS >= 10.8 ✔
==> Options
--without-cgo
    Build without cgo (also disables race detector)
--without-race
    Build without race detector
--HEAD
    Install HEAD version
==> Caveats
A valid GOPATH is required to use the `go get` command.
If $GOPATH is not specified, $HOME/go will be used by default:
  https://golang.org/doc/code.html#GOPATH

You may wish to add the GOROOT-based install location to your PATH:
  export PATH=$PATH:/usr/local/opt/go/libexec/bin

The GoLand configurations is below:
GOROOT GOROOT

GOPATH GOPATH

When you do go build something.go or go isntall something.go that only builds/installs the go package to give you an executable. You will need to run that executable.

The easiest way to run simple Golang programs is simply use go run something.go that will run your go file.

As long as your GOPATH is correctly set it should work

It looks like you are trying to run a non main package. Specifically, instead of package HelloWorldProject, you should use package main. After that the IDE will be able to not only build but also run the package.

you can try to change the package name instead of main