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?