Set version command output to Stdout (#1869)

This commit is contained in:
Borja Clemente 2021-03-24 17:43:56 +01:00 committed by GitHub
parent 82778e2f9f
commit 814bf0e0ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ package commands
import ( import (
"encoding/json" "encoding/json"
"fmt"
"strings" "strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -35,7 +36,7 @@ func (e *Executor) initVersion() {
RunE: func(cmd *cobra.Command, _ []string) error { RunE: func(cmd *cobra.Command, _ []string) error {
switch strings.ToLower(e.cfg.Version.Format) { switch strings.ToLower(e.cfg.Version.Format) {
case "short": case "short":
cmd.Println(e.version) fmt.Println(e.version)
case "json": case "json":
ver := jsonVersion{ ver := jsonVersion{
Version: e.version, Version: e.version,
@ -46,9 +47,9 @@ func (e *Executor) initVersion() {
if err != nil { if err != nil {
return err return err
} }
cmd.Println(string(data)) fmt.Println(string(data))
default: default:
cmd.Printf("golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date) fmt.Printf("golangci-lint has version %s built from %s on %s\n", e.version, e.commit, e.date)
} }
return nil return nil
}, },