Setup of Go environment under Windows and Mac

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

I. Install the language pack for go and I'll unzip the Go language pack to the bottom of E:\go

Setting System Environment variables

1, new environment variable name:GorootVariable Value:E:\go  //According to the directory you have stored to modify2, new environment variable name:GOBINvariable Value:%Goroot%\binch(if this is not set, the default will be put in the go installed bin)3, Environment variablesPathIncrease in    %Goroot%\binch
4.新建环境变量: GOPATH  变量值: E:\gowww
  Add%gopath%\bin to the environment variable path  
5. Use go env at the command line to view the configuration of environment variables

Two. Download the GIT bash installation

Open the Git tool. Create a new file and SRC,CD under Gowww e:/gowww/src

go get github.com/astaxie/beego

Install the Bee to e:/gowww/

go get github.com/astaxie/bee(这个路径我在window下使用好像是可以的,在Mac下面就不行了)
So use go get Github.com/beego/bee
Three. Installation using Liteide

View---Edit the current environment

# Native Compiler Windows 386
Goroot=e:\go
#GOBIN =
Goarch=386
Goos=windows
Cgo_enabled=1
Gopath=e:\gowww
path=c:\mingw32\bin;%goroot%\bin;%path%
#LITEIDE_GDB =gdb
Liteide_make=mingw32-make
liteide_term=%comspec%
liteide_termargs=
liteide_exec=%comspec%
Liteide_execopt=/c

Installing the Bee tool under Mac

Issue 1: When installing the Bee tool, the following problem occurred and could not find the compiled go source file

Go get github.com/astaxie/beepackage github.com/astaxie/bee:no buildable go source files in/users/liuzhenpeng/gowww/ Src/github.com/astaxie/bee

Cause and resolution: mainly because of the use of Go get github.com/astaxie/bee, in fact, this path is not correct, but to use go get Github.com/beego/bee (Beego's official website is better)

Issue 2: The following issue occurs when installing the Bee tool

Go install github.com/beego/bee:open/usr/local/go/bin/bee:permission denied

Cause and resolution: mainly because on the Mac download the installation, if not in the user's home directory files, the user is not authorized, so the bee file is not written in. (without this problem under window)

Workaround One: You can modify the genus owner of the/usr/local/go/bin and change it to be a permission that the user can use, but I do not recommend it.

Workaround Two: Modify the Go ENV environment variable Gobin Let it write Bee file under/users/liuzhenpeng/gowww/bin, so that the file write has permission.

If the Gobin in Go env is empty or is set to/usr/local/go/bin then the Bee file is written to/usr/local/go/bin by default during installation.

Ways to modify Gobin: Vim ~/.bash_progile (No. bash_profile file creates one)

Export gopath=~/gowww/

Export gobin= $GOPATH/bin

Export path= $PATH: GOBIN (add GOBIN to environment variable, wait for the installation to succeed, bee in ~/gowww/bin/bee, you can directly use

SOURCE ~/.bash_profile (Let it take effect immediately, can be viewed through Go env, echo $PATH to view the content)


Issue 3: When installing the Bee tool with sudo

Package Github.com/beego/bee:cannot Download, $GOPATH not set. For more details See:go help Gopath


Cause and Resolution: Although the current user has set Gopath, but this gopath is set under the ~/.bash_profile, so it is only your variable, but when you switch to the root user through sudo, he did not gopath this variable, so said $GOPATH not set




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.