dev: display version in verbose mode (#4771)
This commit is contained in:
parent
88f60c8c5c
commit
b9a67e6883
@ -152,6 +152,8 @@ func (c *runCommand) persistentPreRunE(cmd *cobra.Command, args []string) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.log.Infof(c.buildInfo.String())
|
||||||
|
|
||||||
loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)
|
loader := config.NewLoader(c.log.Child(logutils.DebugKeyConfigReader), c.viper, cmd.Flags(), c.opts.LoaderOptions, c.cfg, args)
|
||||||
|
|
||||||
err := loader.Load(config.LoadOptions{CheckDeprecation: true, Validation: true})
|
err := loader.Load(config.LoadOptions{CheckDeprecation: true, Validation: true})
|
||||||
|
@ -19,6 +19,11 @@ type BuildInfo struct {
|
|||||||
Date string `json:"date"`
|
Date string `json:"date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b BuildInfo) String() string {
|
||||||
|
return fmt.Sprintf("golangci-lint has version %s built with %s from %s on %s",
|
||||||
|
b.Version, b.GoVersion, b.Commit, b.Date)
|
||||||
|
}
|
||||||
|
|
||||||
type versionInfo struct {
|
type versionInfo struct {
|
||||||
Info BuildInfo
|
Info BuildInfo
|
||||||
BuildInfo *debug.BuildInfo
|
BuildInfo *debug.BuildInfo
|
||||||
@ -92,7 +97,6 @@ func (c *versionCommand) execute(_ *cobra.Command, _ []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printVersion(w io.Writer, info BuildInfo) error {
|
func printVersion(w io.Writer, info BuildInfo) error {
|
||||||
_, err := fmt.Fprintf(w, "golangci-lint has version %s built with %s from %s on %s\n",
|
_, err := fmt.Fprintln(w, info.String())
|
||||||
info.Version, info.GoVersion, info.Commit, info.Date)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user