[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

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] Re: Correct use of bufio.Reader

2023-02-06 Thread kristo
Some data might have been read even if err != nil. Maybe always printing out msg could give you a hint? https://pkg.go.dev/bufio#Reader.ReadBytes -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving e

[go-nuts] Why do x509.CertificateRequest ExtraExtensions become attributes?

2023-02-06 Thread Mauro Monteiro
Hello all I am using go crypto libs to create x509 certificate requests (CSR) and certificates. I noticed that CSR template extra extensions become CSR template attributes in case I need to marshal / unmarshal csr templates. For instance, below is a simple code that shows this behaviour: c

Re: [go-nuts] How to correctly use exec.Command and properly clean up all pipes

2023-02-06 Thread 'Lucas Christian' via golang-nuts
Filed under https://github.com/golang/go/issues/58369. -- Lucas Christian Staff Software Engineer, Voice and SIP Connectivity On Fri, Feb 3, 2023 at 2:14 PM Ian Lance Taylor wrote: > On Fri, Feb 3, 2023 at 1:48 PM Lucas Christian > wrote: > > > > Thanks for the reply and confirmation—theoretic

[go-nuts] how to get the json line number when getting unmarshal errors?

2023-02-06 Thread dave
I'm getting the error panic: json: cannot unmarshal string into Go value of type map[string]*json.RawMessage but it does not tell me which line or section of my json is causing the issue. How can I see this? -- You received this message because you are subscribed to the Google Groups "golan

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] how to get the json line number when getting unmarshal errors?

2023-02-06 Thread 'Axel Wagner' via golang-nuts
The best method I've found is to wrap the input reader in something that keeps track of lines. You can then type-assert the errors to one of the exported error types in the json package to get the offset the error occured and translate it into line numbers using your wrapper. I have a package for s

Re: [go-nuts] how to get the json line number when getting unmarshal errors?

2023-02-06 Thread Ian Lance Taylor
On Mon, Feb 6, 2023 at 4:50 PM 'Axel Wagner' via golang-nuts wrote: > > The best method I've found is to wrap the input reader in something that > keeps track of lines. You can then type-assert the errors to one of the > exported error types in the json package to get the offset the error occure