迫于落后,想问问 go1.7 以后,生成 binary package 有变化吗?

2018-10-08 18:08:28 +08:00
 ChristopherWu

鉴于以前实习需要生成 binary package,但是当时生成规则比较麻烦,还需要逐个逐个生成 fake 文件,于是写了个小工具。

见此文章: https://yonghaowu.github.io/2016/11/09/GolangBinaryPackage/

今天见有人 star 了,又落后没有接触 go 快一年了,于是想问问,现在生成的方式有变化吗?这个方法是最合适的吗?有人做出好用的工具吗?

1865 次点击
所在节点    程序员
4 条回复
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.
fuxiaohei
2018-10-08 18:45:49 +08:00
去查 //go:binary-only-package
ChristopherWu
2018-10-08 19:18:02 +08:00
@Septembers 谢谢大佬,请问是什么时候出的呢?(懒得查了,不知道关键字,go 也不好切版本文档。。)
Septembers
2018-10-08 19:40:52 +08:00

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/495685

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX