GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — runtime/debug: document BuildInfo.Main.Version == "(devel)" · Issue #29228 · golang/go

runtime/debug: document BuildInfo.Main.Version == "(devel)" #29228

New issue
Copy link
New issue
Copy link
Open
Open
runtime/debug: document BuildInfo.Main.Version == "(devel)"#29228
Copy link
Labels
DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules
Milestone
Backlog

Description

@mark-rushakoff
mark-rushakoff
opened on Dec 13, 2018
Issue body actions

What version of Go are you using (go version)?

$ go version
go version devel +571d93e977 Thu Dec 13 15:08:48 2018 +0000 darwin/amd64

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mr/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mr/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/mr/gotip/src/github.com/golang/go"
GOTMPDIR=""
GOTOOLDIR="/Users/mr/gotip/src/github.com/golang/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/mr/gomod/debug-module-version-demo/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ct/bl4_z3g51ks8239_r2k07v_40000gn/T/go-build638578617=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Repro case is https://github.com/mark-rushakoff/debug-module-version-demo. It's a module, and its main.go contents are a simple use of debug.ReadBuildInfo:

package main

import (
	"fmt"
	"runtime/debug"

	_ "rsc.io/quote"
)

func main() {
	bi, ok := debug.ReadBuildInfo()
	if !ok {
		panic("couldn't read build info")
	}

	fmt.Printf("%s version %s\n", bi.Path, bi.Main.Version)

	for _, d := range bi.Deps {
		fmt.Printf("\tbuilt with %s version %s\n", d.Path, d.Version)
	}
}

What did you expect to see?

I expected to see the first line print github.com/mark-rushakoff/debug-module-version-demo version v0.0.0-20181213... when checked out at an arbitrary commit, or github.com/mark-rushakoff/debug-module-version-demo version v0.0.1 when checked out at tag v0.0.1. I tried both go run . and go build . && ./debug-module-version-demo but both cases printed (devel).

What did you see instead?

github.com/mark-rushakoff/debug-module-version-demo version (devel)
	built with golang.org/x/text version v0.0.0-20170915032832-14c0d48ead0c
	built with rsc.io/quote version v1.5.2
	built with rsc.io/sampler version v1.3.0

Based on the behavior I've observed, it looks as though the main module returned by debug.ReadBuildInfo is hardcoded to (devel) for the main module, which I assume is intended behavior. If so, that's unfortunate for use cases like mycmd version to easily print the module version of the software being built; but it should be documented.

The current documentation at https://tip.golang.org/pkg/runtime/debug/#ReadBuildInfo does not mention (devel) in any way, nor does it mention any special behavior of the Main module.

/cc @hyangah since you're on git blame for src/runtime/debug/mod.go.

Reacted by Michael Stapelberg, Beni Cherniavsky-Paskin, Matt Holt, theGeekPirate, Ilia Choly, Antoine GIRARD, Filippo Valsorda, Equim, Zik Aeroh, Wayne Ashley Berry and 57 more
Reacted by Roberto Clapis, Yanchen Chen and Dmitry Zinin

Activity

Next
  1. gopherbot
    added
    DocumentationIssues describing a change to documentation.
    on Dec 13, 2018
  2. mark-rushakoff
    changed the title [-]runtime/debug: document BuildInfo.Main.Version == "devel"[/-] [+]runtime/debug: document BuildInfo.Main.Version == "(devel)"[/+] on Dec 13, 2018
  3. bcmills commented on Dec 13, 2018

    @bcmills
    bcmills
    on Dec 13, 2018
    Contributor
    More actions

    We could perhaps detect the case where the main module happens to be a pristine checkout with a semantically-versioned tag, although that might be misleading if some other module has a cyclic requirement specifying a higher version than the tag.

  4. bcmills
    added
    modules
    on Dec 13, 2018
  5. bcmills
    added this to the Go1.12 milestone on Dec 13, 2018
  6. stapelberg commented on Dec 22, 2018

    @stapelberg
    stapelberg
    on Dec 22, 2018
    Contributor
    More actions

    +1.

    I thought being able to print the program’s main module’s version was the whole point of embedding build information into the binary.

    Reacted by Tv, Alexander Neumann, Beni Cherniavsky-Paskin, Jeff Allen, hexaflex-zz, Matt Holt, Victor Luft, theGeekPirate, Ilia Choly, Dominik Honnef and 89 more
  7. mark-rushakoff commented on Jan 7, 2019

    @mark-rushakoff
    mark-rushakoff
    on Jan 7, 2019
    ContributorAuthor
    More actions

    #26404 (comment) is some separate uncertainty about when and why (devel) shows up. There are some linked issues there that seem to paint a fuller picture, but I don't have time to go through them right now.

    I think this issue is still fully separate from #26404, as this is just about documenting (devel).

  8. bcmills
    modified the milestones: Go1.12, Go1.13 on Jan 9, 2019
  9. mark-rushakoff commented on Jan 24, 2019

    @mark-rushakoff
    mark-rushakoff
    on Jan 24, 2019
    ContributorAuthor
    More actions

    It looks like one way to get the version to show up, is to make a new module referring to the one you actually want to build; and then build the target module.

    bash-3.2$ gotip mod init ignore
    go: creating new go.mod: module ignore
    
    bash-3.2$ gotip get github.com/mark-rushakoff/debug-module-version-demo
    go: finding github.com/mark-rushakoff/debug-module-version-demo v0.0.1
    go: downloading github.com/mark-rushakoff/debug-module-version-demo v0.0.1
    go: extracting github.com/mark-rushakoff/debug-module-version-demo v0.0.1
    
    bash-3.2$ gotip build !$
    gotip build github.com/mark-rushakoff/debug-module-version-demo
    
    bash-3.2$ ./debug-module-version-demo
    github.com/mark-rushakoff/debug-module-version-demo version v0.0.1
    	built with golang.org/x/text version v0.0.0-20170915032832-14c0d48ead0c
    	built with rsc.io/quote version v1.5.2
    	built with rsc.io/sampler version v1.3.0
    
    Reacted by Matt Holt, Marc Hörsken, Wayne Ashley Berry, Tv and Tyrone
    Reacted by Ilia Choly, Antoine GIRARD, Matt Holt, Alexey Palazhchenko, pymq, Ben Wakeford, Oleg Balunenko, Gregor Best and Glenn 'devalias' Grant
  10. mholt commented on Apr 19, 2019

    @mholt
    mholt
    on Apr 19, 2019
    More actions

    @bcmills

    We could perhaps detect the case where the main module happens to be a pristine checkout with a semantically-versioned tag,

    Or even just any of the current VCS state. For Caddy's builds, we use tag if clean, or if not clean: nearest tag, commit SHA, and build date (although I can understand why build date is a bad idea if seeking reproducible builds).

    For now, @mark-rushakoff's workaround is quite handy.

    +1 to this though, some version info on the main module would be immensely helpful.

    Reacted by James Pirruccello
  11. andybons
    modified the milestones: Go1.13, Go1.14 on Jul 8, 2019
  12. hyangah commented on Aug 29, 2019

    @hyangah
    hyangah
    on Aug 29, 2019
    Contributor
    More actions

    As observed in #33926, currently it's possible to end up building a binary with the same main module version but with different dependency versions. People who intend to use the main module version as the binary version should be careful.

  13. bcmills commented on Sep 3, 2019

    @bcmills
    bcmills
    on Sep 3, 2019
    Contributor
    More actions

    People who intend to use the main module version as the binary version should be careful.

    Using the “main module” version as the binary version (in the sense of https://tip.golang.org/cmd/go/#hdr-The_main_module_and_the_build_list) should be fine as long as the module doesn't have filesystem-local replace directives.

    Unfortunately, that is not the version that the Main field indicates today (see #33975).

    So I agree that the BuildInfo.Main field itself is not really reliable as an indication of the overall configuration in use, even when that version is not (devel).

  14. 23 remaining items

  15. sevein
    added a commit that references this issue on Feb 16, 2022

    adding function to get software agent

    239428e
  16. wafer-bw commented on Mar 21, 2022

    @wafer-bw
    wafer-bw
    on Mar 21, 2022
    More actions

    Is this not supposed to be added in go1.18? The release notes seem to indicate such but the module version still reads as (devel) when building in the same directory as the .git folder in a repo with a tag.

    Reacted by Rob Prentiss, Rodrigo Chacon, Amnon, Kemal Akkoyun and Glenn 'devalias' Grant
  17. seankhliao commented on Mar 21, 2022

    @seankhliao
    seankhliao
    on Mar 21, 2022
    Member
    More actions

    1.18 stamps vcs info but not as the version, that's #50603

  18. james-rms
    added a commit that references this issue on Oct 13, 2022

    go: use internal version string (#649)

    7425b07
  19. mwhittaker
    added a commit that references this issue on Jun 15, 2023

    Fixed buggy `weaver version` output.

    c06ac11
  20. mwhittaker
    added 5 commits that reference this issue on Jun 23, 2023

    Fixed buggy `weaver version` output.

    8e145f0

    Fixed buggy `weaver version` output.

    99a2cf7

    Added hardcoded weaver module version.

    3baf984

    Added hardcoded weaver module version.

    5e6fbef

    Added hardcoded weaver module version.

    51bb741
  21. 0xdevalias commented on Nov 28, 2023

    @0xdevalias
    0xdevalias
    on Nov 28, 2023
    More actions

    1.18 stamps vcs info but not as the version, that's #50603

    I was wondering if there have been any updates on this since the last comment in March 2022; potentially in other issue's I may not be aware of?

    Reacted by DeedleFake, Yang Hanlin and pematt
  22. seankhliao
    added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Jul 13, 2024
  23. ulope
    added a commit that references this issue on Jul 16, 2024

    Properly include source version in the binary and expose in metrics

    f21a5db
  24. seankhliao commented on Mar 22, 2025

    @seankhliao
    seankhliao
    on Mar 22, 2025
    Member
    More actions

    This should happen less often with #50603

    Reacted by Matt Holt
  25. mmedum
    added a commit that references this issue on Apr 26, 2026

    Add internal/version + internal/config packages

    7ab10ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

      Milestone

      • BacklogNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.