Re: [go-nuts] extract VCS branch name used during build

2023-02-08 Thread quin...@gmail.com
Thanks for the ideas all, I think go embed is the best path for me. runtime/debug will give me the revision but sadly it can't give me the branch. I want the branch as we run a microservice architecture and seeing that all the microservices are running the release branch and not master (or mai

Re: [go-nuts] extract VCS branch name used during build

2023-02-07 Thread Tobias Klausmann
Hi! On Mon, 06 Feb 2023, quin...@gmail.com wrote: > I would like to be able to extract the VCS branch name used during build. > Currently I append "-X main.BranchName=${BRANCH}" to the build line which > works, but I was hoping there might be a cunning way to extract this from > runtime/debug?

Re: [go-nuts] extract VCS branch name used during build

2023-02-06 Thread Duncan Harris
Do you really need the branch? You get the commit hash for free since Go 1.18 : https://tip.golang.org/doc/go1.18#go-version You can see the embedded version information with: go version -m On Monday, 6 February 2023 at 17:33:53 UTC burker...@gmail.com wrote: > You can use go:generate and go:e

Re: [go-nuts] extract VCS branch name used during build

2023-02-06 Thread Chris Burkert
You can use go:generate and go:embed to achieve this. In our CI/CD pipeline we generate a json file with a lot of information like vcs, branch, tag, date and time, hash and a lot more. Then we embed this json into the binary. I became aware of this technique from https://levelup.gitconnected.com/a

[go-nuts] extract VCS branch name used during build

2023-02-06 Thread quin...@gmail.com
Hi, I would like to be able to extract the VCS branch name used during build. Currently I append "-X main.BranchName=${BRANCH}" to the build line which works, but I was hoping there might be a cunning way to extract this from runtime/debug? Thanks, -Steve -- You received this message becaus