I'm writing two binaries, and both of them use two libraries (we can call them libA and libB).
Each lib is in a dedicated git repo, with git-tags to declare versions. For example, libA is at v1.0.9 and libB is v0.0.12.
Both binaries have CLI flags, and I would like to add a debug flag to display lib versions like that:
> ./prog -d
Used libraries:
- libA, v1.0.9
- libB, v0.0.12
I don't know how to do that.
The only way I see to set variable from "outside" is to use ldflags (go build -ldflags="-X 'main.Version=v1.0.0'"
for example). But this way don't seems scalable, how to add a libC? It also imply to manage tags two times, one time for git, and one time in goreleaser.yml or makefile.
Can you help me to find a solution?