鉴于以前实习需要生成 binary package,但是当时生成规则比较麻烦,还需要逐个逐个生成 fake 文件,于是写了个小工具。
见此文章: https://yonghaowu.github.io/2016/11/09/GolangBinaryPackage/
今天见有人 star 了,又落后没有接触 go 快一年了,于是想问问,现在生成的方式有变化吗?这个方法是最合适的吗?有人做出好用的工具吗?
1
Septembers 2018-10-08 18:38:40 +08:00
-buildmode 了解一下
see https://golang.org/cmd/go/#hdr-Build_modes -buildmode=archive Build the listed non-main packages into .a files. Packages named main are ignored. -buildmode=c-archive Build the listed main package, plus all packages it imports, into a C archive file. The only callable symbols will be those functions exported using a cgo //export comment. Requires exactly one main package to be listed. -buildmode=c-shared Build the listed main package, plus all packages it imports, into a C shared library. The only callable symbols will be those functions exported using a cgo //export comment. Requires exactly one main package to be listed. -buildmode=shared Combine all the listed non-main packages into a single shared library that will be used when building with the -linkshared option. Packages named main are ignored. |
2
fuxiaohei 2018-10-08 18:45:49 +08:00
去查 //go:binary-only-package
|
3
ChristopherWu OP @Septembers 谢谢大佬,请问是什么时候出的呢?(懒得查了,不知道关键字,go 也不好切版本文档。。)
|
4
Septembers 2018-10-08 19:40:52 +08:00 via Android
|