-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add buildinfo flag #6286
base: main
Are you sure you want to change the base?
Add buildinfo flag #6286
Conversation
Signed-off-by: Alex Bozhenko <alexbozhenko@gmail.com>
0312ed4
to
b5fe72d
Compare
func PrintBuildinfoAndExit() { | ||
bi, ok := debug.ReadBuildInfo() | ||
if !ok || bi == nil { | ||
//nolint:forbidigo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neilalexander ok to ignore like this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it is a pretty niche desire for wanting to read the build info if you do not have Go installed. That said, I suppose there is no harm in adding a CLI option as long as it does not introducing breaking changes.
@@ -5676,10 +5676,11 @@ func getDefaultAuthTimeout(tls *tls.Config, tlsTimeout float64) float64 { | |||
// specific flags. On success, an options structure is returned configured | |||
// based on the selected flags and/or configuration file. | |||
// The command line options take precedence to the ones in the configuration file. | |||
func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, printTLSHelp func()) (*Options, error) { | |||
func ConfigureOptions(fs *flag.FlagSet, args []string, printVersion, printHelp, printBuildinfo, printTLSHelp func()) (*Options, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Embedding the NATS server is quite common and since this is a public function, this is a breaking change we don't want to do.
// ProcessCommandLineArgs takes the command line arguments | ||
// validating and setting flags for handling in case any | ||
// sub command was present. | ||
func ProcessCommandLineArgs(cmd *flag.FlagSet) (showVersion bool, showHelp bool, err error) { | ||
func ProcessCommandLineArgs(cmd *flag.FlagSet) (showVersion bool, showHelp bool, showBuildinfo bool, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, this is a breaking change.
This information is already available through
go version -m path/to/binary
But it will be more convenient to have it available without go installed.
Test plan:
go build .
./nats-server -buildinfo
./nats-server buildinfo
./nats-server --buildinfo
All return:
Signed-off-by: Alex Bozhenko alex@synadia.com