V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
ChristopherWu
V2EX  ›  程序员

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

  •  
  •   ChristopherWu · 2018-10-08 18:08:28 +08:00 · 1793 次点击
    这是一个创建于 2024 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

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

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

    4 条回复    2018-10-08 19:40:52 +08:00
    Septembers
        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.
    fuxiaohei
        2
    fuxiaohei  
       2018-10-08 18:45:49 +08:00
    去查 //go:binary-only-package
    ChristopherWu
        3
    ChristopherWu  
    OP
       2018-10-08 19:18:02 +08:00
    @Septembers 谢谢大佬,请问是什么时候出的呢?(懒得查了,不知道关键字,go 也不好切版本文档。。)
    Septembers
        4
    Septembers  
       2018-10-08 19:40:52 +08:00 via Android
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5731 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:38 · PVG 10:38 · LAX 19:38 · JFK 22:38
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.