charmbracelet / charmbracelet/fang
`--version` only shows VCS information when using `go install`
- Dominant language
- Go
- Stars
- 1.9k
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
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.
https://github.com/charmbracelet/fang/blob/055c2e3dda070c20c9ff8f6df793131d8bf63696/fang.go#L197
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'.
Contributor guide
Research direction
Start in fang.go around line 197 and inspect how debug.ReadBuildInfo fields are used for --version. Reproduce the behavior with go run and a built binary, comparing it with go install. Done means the limitation is documented and the issue's requested handling of available VCS information is addressed or its constraints are clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100