I hadn't realised about debug.BuildInfo - thanks!

On Tuesday, November 1, 2022 at 9:15:02 PM UTC axel.wa...@googlemail.com 
wrote:

> It feels like an oversight not to mention debug.BuildInfo 
> <https://pkg.go.dev/runtime/debug@go1.19.2#BuildInfo> here. No CI/CD or 
> manual build steps required.
>
> On Tue, Nov 1, 2022 at 9:55 PM Chris Burkert <burker...@gmail.com> wrote:
>
>> During CI/CD we create a json file with a few details (git tag, branch, 
>> hash, date, time). Afterwards we compile Go Code which embeds this file 
>> into the binary. During runtime flags like --version print the json.
>>
>> Note that this is about the version of some binary - not the version of a 
>> package. However, you could embed go.mod. But there may be better ways.
>>
>> Hope this helps.
>>
>> 'Mark' via golang-nuts <golan...@googlegroups.com> schrieb am Di. 1. 
>> Nov. 2022 um 16:34:
>>
>>> I am creating a pkg.
>>> It has a `go.mod` file:
>>> ```
>>> module github.com/.../mypkg
>>>
>>> go 1.19
>>> ```
>>> And code files with functions in .go files all in the mypkg pkg.
>>>
>>> How do I specify which version the mypkg pkg is? I know about using `$ 
>>> git tag vX.Y.Z` and `$ git push origin vX.Y.Z`, but is there any way I can 
>>> have this version in a file that can be accessed at build time or runtime?
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to golang-nuts...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/golang-nuts/0a16b738-59e5-4885-90c8-cd168e308623n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/golang-nuts/0a16b738-59e5-4885-90c8-cd168e308623n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to golang-nuts...@googlegroups.com.
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/golang-nuts/CALWqRZov4r%2BN2FiZug5mmwUwhYcvf08922UQU%3DMqfJKLFT8dBg%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/golang-nuts/CALWqRZov4r%2BN2FiZug5mmwUwhYcvf08922UQU%3DMqfJKLFT8dBg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/ac35d44d-5795-45d3-9b46-5bfd643d2a34n%40googlegroups.com.

Reply via email to