Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: improving documentation for when hashes are not included in binaries #50403

Open
d-tsuji opened this issue Jan 1, 2022 · 1 comment
Open

Comments

@d-tsuji
Copy link
Contributor

@d-tsuji d-tsuji commented Jan 1, 2022

I used debug/buildinfo, which will be added in Go 1.18. As far as I can see, the hash is not included if you build it as command-line-arguments as follows.

https://tip.golang.org/doc/go1.18

Version control information is embedded if the go command is invoked in a directory within a Git, Mercurial, Fossil, or Bazaar repository, and the main package and its containing main module are in the same repository.

Do I need to add to the above documentation that hashes are not included if built as command-line-arguments?

Example

  • Directory structure
.
├── go.mod
└── main.go
  • go.mod
module sample

go 1.18
  • main.go
package main

import (
    "fmt"
)

func main() {
    fmt.Println("Hello, world")
}

When built as command-line-arguments

VCS hashes are not included.

$ go build main.go
$ go version -m main
main: go1.18beta1
        path    command-line-arguments
        build   -compiler=gc
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v1

If you build as package name.

VCS hashes are included. This is the behavior we expect in Go 1.18.

$ go build sample
$ go version -m sample
sample: go1.18beta1
        path    sample
        mod     sample  (devel)
        build   -compiler=gc
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v1
        build   vcs=git
        build   vcs.revision=sample0123456789012345678901234567sample
        build   vcs.time=2021-12-27T04:24:55Z
        build   vcs.modified=true

The behavior of whether or not VCS hashes are included in builds with the go build argument is described in the draft release notes, but there is room to improve the documentation.

@gopherbot gopherbot added this to the Proposal milestone Jan 1, 2022
@seankhliao seankhliao changed the title proposal: doc/go1.18: improving documentation for when hashes are not included in binaries doc/go1.18: improving documentation for when hashes are not included in binaries Jan 1, 2022
@seankhliao seankhliao changed the title doc/go1.18: improving documentation for when hashes are not included in binaries cmd/go: improving documentation for when hashes are not included in binaries Jan 1, 2022
@seankhliao seankhliao removed this from the Proposal milestone Jan 1, 2022
@cagedmantis cagedmantis added this to the Backlog milestone Jan 7, 2022
@cagedmantis
Copy link
Contributor

@cagedmantis cagedmantis commented Jan 7, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants