Passed
Push — master ( c22b58...264c22 )
by Abouzar
02:12
created
Severity
1
package main
2
3
import (
4
	"fmt"
5
	"io"
6
	"os"
7
8
	"github.com/fatih/color"
9
	"github.com/mattn/go-colorable"
10
	"github.com/mattn/go-isatty"
11
)
12
13
var (
14
	Stdout     = colorable.NewColorableStdout()
0 ignored issues
show
exported var Stdout should have comment or be unexported
Loading history...
15
	Stderr     = colorable.NewColorableStderr()
16
	Default UI = Console{Stdout: Stdout, Stderr: Stderr}
17
)
18
19
type UI interface {
0 ignored issues
show
exported type UI should have comment or be unexported
Loading history...
20
	Printf(format string, a ...interface{}) (n int, err error)
21
	Println(a ...interface{}) (n int, err error)
22
	Errorf(format string, a ...interface{}) (n int, err error)
23
	Errorln(a ...interface{}) (n int, err error)
24
}
25
26
func Printf(format string, a ...interface{}) (n int, err error) {
0 ignored issues
show
exported function Printf should have comment or be unexported
Loading history...
27
	return Default.Printf(color.CyanString("INFO: ")+format, a...)
0 ignored issues
show
can't check non-constant format in call to Printf
Loading history...
28
}
29
30
func Errorf(format string, a ...interface{}) (n int, err error) {
0 ignored issues
show
exported function Errorf should have comment or be unexported
Loading history...
31
	return Default.Errorf(color.RedString("ERROR: ")+format, a...)
0 ignored issues
show
can't check non-constant format in call to Errorf
Loading history...
32
}
33
34
func Warnf(format string, a ...interface{}) (n int, err error) {
0 ignored issues
show
exported function Warnf should have comment or be unexported
Loading history...
35
	return Default.Errorf(color.YellowString("WARN: ")+format, a...)
0 ignored issues
show
can't check non-constant format in call to Errorf
Loading history...
36
}
37
38
func Errorln(a ...interface{}) (n int, err error) {
0 ignored issues
show
exported function Errorln should have comment or be unexported
Loading history...
39
	return Default.Errorln(a...)
40
}
41
42
func IsTerminal(f *os.File) bool {
0 ignored issues
show
exported function IsTerminal should have comment or be unexported
Loading history...
43
	return isatty.IsTerminal(f.Fd())
44
}
45
46
type Console struct {
0 ignored issues
show
exported type Console should have comment or be unexported
Loading history...
47
	Stdout io.Writer
48
	Stderr io.Writer
49
}
50
51
func (c Console) Printf(format string, a ...interface{}) (n int, err error) {
0 ignored issues
show
exported method Console.Printf should have comment or be unexported
Loading history...
52
	return fmt.Fprintf(c.Stdout, format, a...)
0 ignored issues
show
can't check non-constant format in call to Fprintf
Loading history...
53
}
54
55
func (c Console) Println(a ...interface{}) (n int, err error) {
0 ignored issues
show
exported method Console.Println should have comment or be unexported
Loading history...
56
	return fmt.Fprintln(c.Stdout, a...)
57
}
58
59
func (c Console) Errorf(format string, a ...interface{}) (n int, err error) {
0 ignored issues
show
exported method Console.Errorf should have comment or be unexported
Loading history...
60
	return fmt.Fprintf(c.Stderr, format, a...)
0 ignored issues
show
can't check non-constant format in call to Fprintf
Loading history...
61
}
62
63
func (c Console) Errorln(a ...interface{}) (n int, err error) {
0 ignored issues
show
exported method Console.Errorln should have comment or be unexported
Loading history...
64
	return fmt.Fprintln(c.Stderr, a...)
65
}
66