duandi1636 2019-09-23 13:47
浏览 94

试图了解go build -tags static

I'm starting to develop a few services in Go, and I'm having some issues trying to understand how to and when to use build -tags flag.

My build image is the official golang:1.13.0-stretch in which I also add librdkafka. Then I build my app with GOOS=linux GOARCH=amd64 go build -tags static_all main.go (also tried static).

Problem is, if I just get the binary from the builder for my final image (using ubuntu, not scratch), the app will fail unless I install librdkafka, or just copy /usr/lib/librdkafka* from builder to /usr/lib/.

If I understood the flag correctly, -tags static / static_all is to compile the app with all the libs it needs (at expense of bigger size), so that I can seamlessly deploy it in any system (even though in this case it's the same). But it looks like it's not working like that, because I'm still having the requirement to provide librdkafka to the target system (image in this case)

So, in summary:

  • How do I know when I have to use -tags static?

  • Where can I find a list of available tags and their purpose?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)