分类
golang

Go GoLand 配置

GOROOT 使用 brew install go 下载

GOPATH

mkdir -p /Users/jpuyy/go

Editor/General/Appearance/Show whitespaces

配置 File Watchers 进行 gofmt

分类
golang

golang 交叉编译

编译 linux 64 位

GOOS=linux GOARCH=amd64 go build

编译 mac 64 位

GOOS=darwin GOARCH=amd64 go build
分类
golang

go test

ok   command-line-arguments (cached)

禁用 cache 进行测试

go test api/cmdb/client_test.go -count=1
分类
golang

brew 切换 go 版本

安装

brew install go

查看所有版本 方式一

jpuyy-mba:src jpuyy$ brew info go
go: stable 1.11.4 (bottled), HEAD
Open source programming language to build simple/reliable/efficient software
https://golang.org
/usr/local/Cellar/go/1.10.3 (8,170 files, 336.8MB)
  Poured from bottle on 2018-07-31 at 17:27:27
/usr/local/Cellar/go/1.11 (9,273 files, 403.9MB) *
  Poured from bottle on 2018-09-29 at 11:39:50

查看所有版本 方式二

brew ls --versions | grep go 
go 1.10.3 1.11 1.11.4

切换

brew switch go 1.11

 

清理旧版本

brew cleanup go
Removing: /usr/local/Cellar/go/1.10.3... (8,170 files, 336.8MB)
Removing: /usr/local/Cellar/go/1.11... (9,273 files, 403.9MB)
Removing: /Users/jpuyy/Library/Caches/Homebrew/go--1.11.sierra.bottle.tar.gz... (140.4MB)

升级新版本

brew upgrade go
分类
golang

govendor 使用

install

go get -u github.com/kardianos/govendor

初始化

govendor init
govendor fetch +outside