What is `go version` based on?

174 views
Skip to first unread message

Jean de Klerk

unread,
Aug 3, 2018, 1:18:35 PM8/3/18
to golang-dev
I'm new to developing on Go, apologies for the noob question:

When I run `make.bash` and then `~/workspace/godevelopment/bin/go version`, I get: `go version devel +30c7878891 Wed Aug 1 15:32:47 2018 -0700 darwin/amd64`

That's odd, because today is 3 Aug.

Furthermore, when I `ls -l ~/workspace/godevelopment/bin/` I get: `-rwxr-xr-x  1 deklerk  5001  12703932 Aug  3 10:10 go`

3 Aug - that is what I expected. So clearly the version is not "when was this binary built". If that's the case... what does version mean? (not being snarky, just want to know heh)

Thanks for any tips!
Jean

Vasko Zdravevski

unread,
Aug 3, 2018, 1:41:02 PM8/3/18
to golang-dev
Hi Jean,

A file called zversion.go is generated by go tool dist. 

You probably just need to delete this file and let it get regenerated: go/src/runtime/internal/sys/zversion.go

// Code generated by go tool dist; DO NOT EDIT.
package sys
const TheVersion = `devel +1b870077c8 Fri Aug 3 17:21:10 2018 +0000`
const Goexperiment = ``
const StackGuardMultiplier = 1

In general, I rebuild from source safely by removing everything: git clean -dffx

You can find this by searching from runtime.Version() and following it down into the internal packages.

Hope this helps.
- Vasko.

Ian Lance Taylor

unread,
Aug 3, 2018, 1:51:29 PM8/3/18
to Vasko Zdravevski, golang-dev
On Fri, Aug 3, 2018 at 10:33 AM, Vasko Zdravevski <vzdra...@gmail.com> wrote:
> Hi Jean,
>
> A file called zversion.go is generated by go tool dist.
>
> You probably just need to delete this file and let it get regenerated:
> go/src/runtime/internal/sys/zversion.go
>
>> // Code generated by go tool dist; DO NOT EDIT.
>> package sys
>> const TheVersion = `devel +1b870077c8 Fri Aug 3 17:21:10 2018 +0000`
>> const Goexperiment = ``
>> const StackGuardMultiplier = 1
>
>
> In general, I rebuild from source safely by removing everything: git clean
> -dffx
>
> You can find this by searching from runtime.Version() and following it down
> into the internal packages.

To expand on that, the version is computed by the function
findgoversion in cmd/dist/build.go. As you can see from that
function, the dates of the files in your repo is not directly
relevant. When working on a development branch what matters is the
output of

git log -n 1 '--format=format: +%h %cd' HEAD

Ian


> On Friday, August 3, 2018 at 11:18:35 AM UTC-6, Jean de Klerk wrote:
>>
>> I'm new to developing on Go, apologies for the noob question:
>>
>> When I run `make.bash` and then `~/workspace/godevelopment/bin/go
>> version`, I get: `go version devel +30c7878891 Wed Aug 1 15:32:47 2018 -0700
>> darwin/amd64`
>>
>> That's odd, because today is 3 Aug.
>>
>> Furthermore, when I `ls -l ~/workspace/godevelopment/bin/` I get:
>> `-rwxr-xr-x 1 deklerk 5001 12703932 Aug 3 10:10 go`
>>
>> 3 Aug - that is what I expected. So clearly the version is not "when was
>> this binary built". If that's the case... what does version mean? (not being
>> snarky, just want to know heh)
>>
>> Thanks for any tips!
>> Jean
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-dev+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Jean de Klerk

unread,
Aug 6, 2018, 5:07:27 AM8/6/18
to golang-dev
Thank you, that clears it up!

Jean
Reply all
Reply to author
Forward
0 new messages