win10 bash下 go环境安装

下载与安装

由于我的系统为64位 win10,运行环境中bash(ubuntu) 在cmd下输入bash,使用uname可以看 Linux DESKTOP-GFJ62ND 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux 说明是linux 64位

进入这官网 https://golang.org/dl/ 找到对应的安装包,以下为安装命令

 wget https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz
 tar zxvf go1.8.1.linux-amd64.tar.gz -C /usr/local/

设置环境变量

在/etc/profile中添加GOROOT, GOBIN, PATH环境变量 vi /etc/profile 在文件后面加上

export GOROOT=/usr/local/go  
export GOBIN=$GOROOT/bin  
export PATH=$PATH:$GOBIN  

最后运行souce /etc/source 再次运行go 如果能看到

Go is a tool for managing Go source code.

Usage:

        go command [arguments]

The commands are:

        build       compile packages and dependencies
        clean       remove object files
        doc         show documentation for package or symbol
        env         print Go environment information
        bug         start a bug report
        fix         run go tool fix on packages
        fmt         run gofmt on package sources
        generate    generate Go files by processing source
        get         download and install packages and dependencies
        install     compile and install packages and dependencies
        list        list packages
        run         compile and run Go program
        test        test packages
        tool        run specified go tool
        version     print Go version
        vet         run go tool vet on packages

Use "go help [command]" for more information about a command.

Additional help topics:

        c           calling between Go and C
        buildmode   description of build modes
        filetype    file types
        gopath      GOPATH environment variable
        environment environment variables
        importpath  import path syntax
        packages    description of package lists
        testflag    description of testing flags
        testfunc    description of testing functions

Use "go help [topic]" for more information about that topic.  

到此说明安装成功

创建工作目录,设置工作目录

cd /mnt/d/workspace  
mdkir -p go/gochard  
cd go/gochard  
export GOPATH=/mnt/d/workspace/go/gochard  

到此工作目录已经创建完成,可以开始编码了。