Skip to content

--version only shows VCS information when using go install #74

@wjam

Description

@wjam

When using this library to build a CLI tool, any call to --version (either through go run . or by running go build and then on the built binary) returns the default 'no VCS information' message.

Looking at the output of debug.ReadBuildInfo, I can see that the Version field is populated but it is missing any value in the Sum field so this line fails.

fang/fang.go

Line 197 in 055c2e3

if info, ok := debug.ReadBuildInfo(); ok && info.Main.Sum != "" {

From testing, it appears the only way to set this field is to go install the binary. This could be difficult if the VCS repository is private or the code requires some amount of generation before being built.

This limitation seems like it should be documented somewhere. It also seems like there should be a way to just say 'trust the VCS information in the binary'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions