Gos-Golang  - 原生 Go 命令的替代方案
小码哥 2019-08-17 14:44:53

Gos 自称为 “Armed Golang(加强版的 Go)”,定位是原生 go 命令的一个“加强版”解决方案。

据官方介绍可以使用 gos 代替 go:

go get => gos get
go build => gos build
go run => gos run
go ... => gos ...

因为 gos 兼容所有的 go 命令,并且还额外增加了搭载智能 GOPROXY 的 go mod/get,它会自动区分私有和公共仓库,并会智能使用 GOPROXY 下载丢失的软件包。

gos 还有一些额外的命令来增强开发体验:

  cross      用于进行敏捷和快速的交叉编译
  proto      用于进行快速简便的原型文件编译

使用 gos cross 进行简单交叉编译的示例代码:

# Compile Linux platform binaries for the current system architecture
# For example, if your computer are amd64, it will compile main.go into the binary of linux/amd64 architecture.
gos cross main.go linux

# Specify the build platform and architecture
gos cross main.go linux amd64
gos cross main.go linux arm
gos cross main.go linux 386
gos cross main.go windows amd64
gos cross main.go darwin 386

# Compiling binary files for all architectures on the specified platform
gos cross main.go linux all
gos cross main.go windows all

# Compiling binary files for all platforms on the specified architecture
gos cross main.go all amd64

# Trying to compile binary files for all platforms and architectures
gos cross all all