1.下载安装

1.1   linux版本下载:   

wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz --no-check-certificate
tar -C /usr/local -xzf go1.9.2.linux-amd64.tar.gz
2.工作目录和环境配置:

 GOROOT 是golang安装根目录

 GOPATH 是工作目录

PATH会设置下 GOROOT和GOPATH bin目录

vim ~/.bash_profile

export GOROOT=/usr/local/go

export GOPATH=/root/workspace

export PATH=.:$PATH:$GOROOT/bin:$GOPATH/bin

配置成功后  go env 验证一下环境变量是否配置成功

3.编写第一个GO程序

    进入$GOPATH/src/hello 目录下, 目录不存在创建,创建一个新文件命名:hello.go   

package main

import "fmt"

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

编译

$ cd $GOAPTH/src/hello
$ go build

执行

$ ./hello
hello, world

或者直接执行:

go run hello.go

4.开发工具

4.1  liteide安装

      下载成功后默认安装:c:\Go

      a.liteide 官方地址:https://github.com/visualfc/liteide

      b.下载地址:https://sourceforge.net/projects/liteide/

      d.下载成功后解压得到 liteide 目录,将其拷贝到 C:/Go(注:默认安装目录$GOROOT),

      e.打开 c:\go\liteide\bin,为 liteide.exe 创建桌面快捷方式

      f.双击桌面上的 liteide.exe 快捷方式打开 LiteIDE,打开工具栏中的 system 下拉条,选中 win64

       h. 控制台会显示当前环境变量配置:

      

当前环境变更 id "win64"

Found go bin at c:\go\bin\go.exe

GOROOT=c:\go

GOARCH=amd64

GOOS=windows

   ctrl+N 创建一个新项目

 

Ctrl+b 构建项目

 

5.相关资料

http://blog.csdn.net/defonds/article/details/50544208

 

6.相关问题

6.1 exec: "gcc": executable file not found in %PATH%

解决方案:http://www.cnblogs.com/zsy/p/5958170.html

# github.com/toolkits/sys
..\..\..\toolkits\sys\cmd.go:54:9: undefined: syscall.Kill
# github.com/open-falcon/rrdlite
exec: "gcc": executable file not found in %PATH%
错误: 进程退出代码 2.