Merge pull request from golangci/feature/windows-color-support

: support color output on windows
This commit is contained in:
golangci 2018-05-27 08:56:49 +03:00 committed by GitHub
commit fc8b81ee17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions
pkg
commands
printers

@ -7,6 +7,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/golangci/golangci-lint/pkg" "github.com/golangci/golangci-lint/pkg"
"github.com/golangci/golangci-lint/pkg/printers"
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
@ -21,7 +22,7 @@ func (e *Executor) initLinters() {
func printLinterConfigs(lcs []pkg.LinterConfig) { func printLinterConfigs(lcs []pkg.LinterConfig) {
for _, lc := range lcs { 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) lc.Linter.Desc(), !lc.DoesFullImport)
} }
} }
@ -48,7 +49,7 @@ func (e Executor) executeLinters(cmd *cobra.Command, args []string) {
for _, linter := range linters { for _, linter := range linters {
linterNames = append(linterNames, linter.Name()) 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) os.Exit(0)

@ -1,8 +1,5 @@
package printers package printers
import ( import "github.com/fatih/color"
"os"
"syscall"
)
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