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

#14: 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

View File

@ -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)

View File

@ -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