Build your go environment under your Mac, and use the IDE

Source: Internet
Author: User
Tags install go
This is a creation in Article, where the information may have evolved or changed.

1, installation

Brew Install Go

2, SET Environment variables:

Gopath is the directory where the program is run
Goroot is the installation directory,

export GOPATH=/Users/songfei/sdk/go export GOBIN=$GOPATH/bin export PATH=$PATH:$GOBIN

3,

$~go env
Goarch= "AMD64"
Gobin= "/users/songfei/sdk/go/bin"
Goexe= ""
Gohostarch= "AMD64"
Gohostos= "Darwin"
Goos= "Darwin"
Gopath= "/users/songfei/sdk/go"
Gorace= ""
goroot= "/usr/local/cellar/go/1.5.2/libexec"
Gotooldir= "/usr/local/cellar/go/1.5.2/libexec/pkg/tool/darwin_amd64"
Go15vendorexperiment= ""
Cc= "Clang"
Gogccflags= "-fpic-m64-pthread-fno-caret-diagnostics-qunused-arguments-fmessage-length=0-fno-common"
cxx= "clang++"
cgo_enabled= "1"

Hello.go

package mainimport "fmt"func main() {fmt.Printf("hello, world\n")}

4, compiled into an executable file

Go Build Hello.go

5, download IDE

IDE Download

Click to view "Edit environment variables

# Native Compiler Drawin AMD64Goroot=/usr/local/cellar/go/1.5.2/libexecGOBIN=/users/songfei/sdk/go/binGoarch=amd64GOOS=darwincgo_enabled=1PATH= $PATH: $GOBINgo15vendorexperiment=1PATH= $GOROOT/bin: $PATHLiteide_gdb=/usr/local/bin/gdbLiteide_make=makeLiteide_term=/usr/bin/openLiteide_termargs=-a Terminalliteide_exec=/usr/x11r6/bin/xtermliteide_execopt=-e

If you run an error in the process:

Golangdoc:could not find Godoc, (Hint:is godoc installed?)

Workaround:

Turn over the wall
Go get-v-u golang.org/x/tools/cmd/godoc

Do not turn over the wall
git clone https://github.com/golang/tools $GOPATH/src/golang.org/x/tools

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.