The current gos is still an alpha version, welcome more people to comment and improve it 🍓, you can add more commands to it, or modify something to make it perform better.
You can download the compiled binary program here: Release Page
from now on, use gos instead of go:
go get => gos get
go build => gos build
go run => gos run
go ... => gos ...
gos is compatible with all go commands and has go mod/get equipped with smart GOPROXY
,
it automatically distinguishes between private and public repositories
and uses GOPROXY
to download your lost package when appropriate.
gos has a few extra commands to enhance your development experience:
cross agile and fast cross compiling
proto quick and easy compilation of proto files
You can use -h
on these sub commands to get more information.
This can't be simpler.
According to your system type, download the zip file from the release page, unzip, rename the binaries to gos
and put it in your $PATH
. Then use gos
as if you were using the go
command.
You can also download the source code and compile it using go build -o gos main.go
Note: The prerequisite for gos to work properly is that the go binary is in your $PATH. If you need to use the gos proto
command, you need the protoc binary too.
You can use gos
just like you would with the go
command. Compatible with all flags and arguments, such as the following:
go get -u -v github.com/xxxx/xxxx
=>
gos get -u -v github.com/xxxx/xxxx
You can use gos cross
command for simpler cross-compilation:
# 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
Gos uses parallel compilation, very fast 🚀, but still depends on the configuration of your operating system.
more information: gos cross -h
This feature may only be useful to RPC developers. You can compile proto files more easily, as follows:
# Compile a single file
gos proto helloworld.proto
# Compile all proto files under the current folder (excluding subfolders)
gos proto all
# Compile all proto files in the current directory and all subdirectories
gos proto all/all
Of course, the precondition is that you have a protoc binary in your $PATH.
more information: gos proto -h
There is a dilemma here. If you don't use GOPROXY
, there may be a large number of Package pull timeouts (network reasons) or non-existence (repository rename, delete or migrate), like the following:
unrecognized import path "golang.org/x/net" ( https fetch: Get https://golang.org/x/net?go-get=1:
dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
If use GOPROXY
, you will not be able to pull the private repositories (github, gitlab, etc) properly, like that:
go get github.com/your_private_repo: unexpected status ( https://athens.azurefd.net/github.com/your_private_repo/@v/list): 500 Internal Server Error
GOS strengthens all of GO's native commands, no matter it's go mod/get/build/run/....Any situation that might cause a package pull, gos will intelligently determine whether the current repository to be pulled needs to use GOPROXY
.
Now, live your thug life 😎
1
Maboroshii 2019-05-21 21:28:21 +08:00 via Android
这个轮子。。。emmmm
|
2
eslizn 2019-05-21 21:39:22 +08:00
一个 makefile 能搞定的事情,一定要开个项目?
|
3
gamexg 2019-05-21 23:53:55 +08:00
交叉编译支持 cgo 吗?
|
4
wweir 2019-05-22 05:50:49 +08:00 via Android
Transparent proxy is a better way, just try sower with socks5 mode.
|
8
storyicon OP @Maboroshii 在使用 GOMODULE 时往往会出现 Internal Server Error 或 Timeout 等问题。
GOPROXY 能够在一定程度上解决在拉取诸如 golang.org/x 包的时候产生的超时问题,也可以在一定程度上解决由于项目改名、迁移、删除等原因导致的 404 问题。 但是需要注意的是,使用 GOPROXY 将导致你无法拉取私有储存库。 GOS 主要解决的是这个问题。 |
12
praynise 2019-05-23 07:28:09 +08:00
star 一下,交叉编译对我来说很有用,gos 方便多了。不过应该还是不支持 CGO 吧?
|
13
storyicon OP @reus 很感谢你提到这点,这对我很有用(其实你可以提一个 issue 方便更多人看到它)。我注意到在 golang/go 的 master 分支上确实已经支持了“ GOPROXY 可以设置多个,用逗号分隔”这个特性,很高兴 Golang 对此作出了改进。
我目前开发使用的版本是 1.12.4,在官网 https://golang.google.cn/dl/最新的发布版本是 1.12.5,目前在这两个版本下,经过我的测试,GOPROXY 都还暂时不支持这个特性,如果包含逗号,将会提示 `invalid $GOPROXY setting: cannot have comma`。 在 master 分支的文档显示,只有在 GOPROXY 服务器返回 404 与 410 时,GOPROXY 才会使用逗号后面的下一个代理进行尝试,不幸的是,大多数主流的 GOPROXY (比如中国常用的 goproxy.io 、微软的 athens )在拉取储存库失败时,返回的是 500 Internal Server Error。这意味着,即使 Golang 的最新发行版支持了这个特性,在相当的一段时间里,可能仍然无法通过设置 GOPROXY=https://goproxy-address,direct 这样的方式,来解决在设置 GOPROXY 的情况下无法正常拉取私有储存库的问题。 如果上面内容有误,还请告知,可能几个小时后我将会把这个问题在 GOS 项目中以文档的形式叙述。 |
14
storyicon OP @praynise Thank you for supporting the development of the open source community 😃
|
17
storyicon OP @reus I describe this here: https://github.com/storyicon/gos/blob/master/docs/on-goproxy.md
|