From c1a55b99d21b02fcd2a5b04e69833e2a2a894f10 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Sun, 13 Jul 2014 11:34:15 -0400 Subject: [PATCH] fmt --- split.go | 66 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/split.go b/split.go index b12fa81..3e4d9fa 100644 --- a/split.go +++ b/split.go @@ -15,8 +15,8 @@ type statement struct { func (s statement) String() string { var buf bytes.Buffer s.each(func(n *node) error { - _, err := fmt.Fprint(&buf, n) - return err + _, err := fmt.Fprint(&buf, n) + return err }) return buf.String() } @@ -24,20 +24,20 @@ func (s statement) String() string { func (s *statement) each(fn func(*node) error) error { curr := s.head for curr != nil { - err := fn(curr) - if err != nil { - return err - } + err := fn(curr) + if err != nil { + return err + } curr = curr.next } - return nil + return nil } func (s *statement) write(w io.Writer) error { - return s.each(func(n *node) error { - _, err := w.Write(n.line) - return err - }) + return s.each(func(n *node) error { + _, err := w.Write(n.line) + return err + }) } type node struct { @@ -54,23 +54,23 @@ func (s *statement) add(line []byte) { if s.head == nil { s.head = n } else if s.head.next == nil { - s.head.next = n - } + s.head.next = n + } if s.tail != nil { s.tail.next = n } - s.tail = n + s.tail = n } func whitespace(buf []byte) bool { - for i, _ := range buf { - switch buf[i] { - case '\r', '\n': - default: - return false - } - } - return true + for i, _ := range buf { + switch buf[i] { + case '\r', '\n': + default: + return false + } + } + return true } func split(r io.Reader, c chan statement) { @@ -82,27 +82,27 @@ func split(r io.Reader, c chan statement) { switch err { case nil: case io.EOF: - if s != nil { - c <- *s - } + if s != nil { + c <- *s + } return default: fmt.Printf("error on read: %v\n", err) return } - if whitespace(line) { - continue - } + if whitespace(line) { + continue + } if line[len(line)-2] != '\r' { fmt.Printf("bad line terminator") break } if line[0] == '*' { - if s != nil { - c <- *s - } - s = new(statement) - s.add(line) + if s != nil { + c <- *s + } + s = new(statement) + s.add(line) } else { if s == nil { fmt.Println("ummm wut")