Eliminate unused functions and type Outlet

This commit is contained in:
Peter Waller
2014-05-21 20:53:09 +01:00
parent 34b39bf589
commit 8b69d28b66
+2 -23
View File
@@ -2,7 +2,6 @@ package main
import (
"bufio"
"bytes"
"fmt"
"github.com/daviddengcn/go-colortext"
"io"
@@ -16,13 +15,6 @@ type OutletFactory struct {
sync.Mutex
}
type Outlet struct {
Name string
Color ct.Color
IsError bool
Factory *OutletFactory
}
var colors = []ct.Color{
ct.Cyan,
ct.Yellow,
@@ -36,27 +28,14 @@ func NewOutletFactory() (of *OutletFactory) {
return new(OutletFactory)
}
func (o *Outlet) Write(b []byte) (num int, err error) {
scanner := bufio.NewScanner(bytes.NewReader(b))
for scanner.Scan() {
o.Factory.WriteLine(o.Name, scanner.Text(), ct.White, ct.None, o.IsError)
}
num = len(b)
return
}
func ProcessOutput(w io.Writer, str string) {
w.Write([]byte(str))
}
func (of *OutletFactory) LineReader(wg *sync.WaitGroup, name string, index int, r io.Reader, isError bool) {
defer wg.Done()
o := &Outlet{name, colors[index%len(colors)], isError, of}
color := colors[index%len(colors)]
scanner := bufio.NewScanner(r)
for scanner.Scan() {
of.WriteLine(o.Name, scanner.Text(), o.Color, ct.None, o.IsError)
of.WriteLine(name, scanner.Text(), color, ct.None, isError)
}
}