Skip to content
  • Patrick Steinhardt's avatar
    feat: add option to derive build info from `debug.BuildInfo` · 4bdf9026
    Patrick Steinhardt authored
    Starting with Go 1.18 the Go toolchain has started to automatically
    attach build information to binaries unless `-buildvcs=false` is passed
    as an option to `go build`. This build information contains various
    pieces of information and has the benefit that it is a standardized way
    to obtain it.
    
    Introduce a new `WithGoBuildInformation()` option that gives callers the
    ability to pass in the build information. Right now it exposes the
    following information:
    
        - The commit from which the software was built from.
    
        - The date when the commit was committed.
    
        - The Go version used to build the binary.
    
        - The module path of the binary's main module.
    
        - The module version of the binary's main module.
    
    So it contains more information than what `WithBuildInformation()` would
    expose right now. There is some difference in behaviour though:
    
        - While both expose the commit the binary was built from the format
          may change. The Go build...
    4bdf9026