grpc-gateway
grpc-gateway copied to clipboard
Use `debug.ReadBuildInfo()` for retrieving a version
🚀 Feature
It's a common case when a developers just installs the utility from sources, without retrieving the binary that includes build info, which raises an issue of tracking the utility's version. Tool dependency has no help in here as mostly developers are installing it via running the command above:
$ go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
which just takes the latest versions of all tools without embedding any information about the utility's build.
I think it's a good idea to retrieve utility's version via debug.ReadBuildInfo
, which was added in Go 1.18.