Explorar o código

go vet && golint

Yasuhiro Matsumoto %!s(int64=9) %!d(string=hai) anos
pai
achega
353693e2f1
Modificáronse 3 ficheiros con 13 adicións e 3 borrados
  1. 3 0
      colorable_others.go
  2. 7 3
      colorable_windows.go
  3. 3 0
      noncolorable.go

+ 3 - 0
colorable_others.go

@@ -7,6 +7,7 @@ import (
 	"os"
 )
 
+// NewColorable return new instance of Writer which handle escape sequence.
 func NewColorable(file *os.File) io.Writer {
 	if file == nil {
 		panic("nil passed instead of *os.File to NewColorable()")
@@ -15,10 +16,12 @@ func NewColorable(file *os.File) io.Writer {
 	return file
 }
 
+// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
 func NewColorableStdout() io.Writer {
 	return os.Stdout
 }
 
+// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
 func NewColorableStderr() io.Writer {
 	return os.Stderr
 }

+ 7 - 3
colorable_windows.go

@@ -75,6 +75,7 @@ type Writer struct {
 	oldattr word
 }
 
+// NewColorable return new instance of Writer which handle escape sequence from File.
 func NewColorable(file *os.File) io.Writer {
 	if file == nil {
 		panic("nil passed instead of *os.File to NewColorable()")
@@ -90,10 +91,12 @@ func NewColorable(file *os.File) io.Writer {
 	}
 }
 
+// NewColorableStdout return new instance of Writer which handle escape sequence for stdout.
 func NewColorableStdout() io.Writer {
 	return NewColorable(os.Stdout)
 }
 
+// NewColorableStderr return new instance of Writer which handle escape sequence for stderr.
 func NewColorableStderr() io.Writer {
 	return NewColorable(os.Stderr)
 }
@@ -357,6 +360,7 @@ var color256 = map[int]int{
 	255: 0xeeeeee,
 }
 
+// Write write data on console
 func (w *Writer) Write(data []byte) (n int, err error) {
 	var csbi consoleScreenBufferInfo
 	procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
@@ -466,7 +470,7 @@ loop:
 				continue
 			}
 			procGetConsoleScreenBufferInfo.Call(uintptr(w.handle), uintptr(unsafe.Pointer(&csbi)))
-			csbi.cursorPosition.x = short(n-1)
+			csbi.cursorPosition.x = short(n - 1)
 			procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
 		case 'H':
 			token := strings.Split(buf.String(), ";")
@@ -481,8 +485,8 @@ loop:
 			if err != nil {
 				continue
 			}
-			csbi.cursorPosition.x = short(n2-1)
-			csbi.cursorPosition.y = short(n1-1)
+			csbi.cursorPosition.x = short(n2 - 1)
+			csbi.cursorPosition.y = short(n1 - 1)
 			procSetConsoleCursorPosition.Call(uintptr(w.handle), *(*uintptr)(unsafe.Pointer(&csbi.cursorPosition)))
 		case 'J':
 			n, err := strconv.Atoi(buf.String())

+ 3 - 0
noncolorable.go

@@ -6,15 +6,18 @@ import (
 	"io"
 )
 
+// NonColorable hold writer but remove escape sequence.
 type NonColorable struct {
 	out     io.Writer
 	lastbuf bytes.Buffer
 }
 
+// NewNonColorable return new instance of Writer which remove escape sequence from Writer.
 func NewNonColorable(w io.Writer) io.Writer {
 	return &NonColorable{out: w}
 }
 
+// Write write data on console
 func (w *NonColorable) Write(data []byte) (n int, err error) {
 	er := bytes.NewBuffer(data)
 loop: