From eea1b93967723ef75234705908a53b0460faf541 Mon Sep 17 00:00:00 2001 From: golangci Date: Sun, 27 May 2018 08:53:55 +0300 Subject: [PATCH] #14: support color output on windows --- pkg/commands/linters.go | 5 +++-- pkg/printers/utils.go | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pkg/commands/linters.go b/pkg/commands/linters.go index d6949623..0e52ed89 100644 --- a/pkg/commands/linters.go +++ b/pkg/commands/linters.go @@ -7,6 +7,7 @@ import ( "github.com/fatih/color" "github.com/golangci/golangci-lint/pkg" + "github.com/golangci/golangci-lint/pkg/printers" "github.com/spf13/cobra" ) @@ -21,7 +22,7 @@ func (e *Executor) initLinters() { func printLinterConfigs(lcs []pkg.LinterConfig) { for _, lc := range lcs { - fmt.Printf("%s: %s [fast: %t]\n", color.YellowString(lc.Linter.Name()), + fmt.Fprintf(printers.StdOut, "%s: %s [fast: %t]\n", color.YellowString(lc.Linter.Name()), lc.Linter.Desc(), !lc.DoesFullImport) } } @@ -48,7 +49,7 @@ func (e Executor) executeLinters(cmd *cobra.Command, args []string) { for _, linter := range linters { linterNames = append(linterNames, linter.Name()) } - fmt.Printf("%s: %s\n", color.YellowString(p), strings.Join(linterNames, ", ")) + fmt.Fprintf(printers.StdOut, "%s: %s\n", color.YellowString(p), strings.Join(linterNames, ", ")) } os.Exit(0) diff --git a/pkg/printers/utils.go b/pkg/printers/utils.go index 913f3181..ace9f57a 100644 --- a/pkg/printers/utils.go +++ b/pkg/printers/utils.go @@ -1,8 +1,5 @@ package printers -import ( - "os" - "syscall" -) +import "github.com/fatih/color" -var StdOut = os.NewFile(uintptr(syscall.Stdout), "/dev/stdout") // was set to /dev/null +var StdOut = color.Output // https://github.com/golangci/golangci-lint/issues/14