Skip to content

Commit a5db08a

Browse files
authored
Omit Write errors (#25)
1 parent 1bec031 commit a5db08a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

ansi/writer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ func (w *Writer) Write(b []byte) (int, error) {
2323
// ANSI escape sequence
2424
w.ansi = true
2525
w.seqchanged = true
26-
w.ansiseq.WriteRune(c)
26+
_, _ = w.ansiseq.WriteRune(c)
2727
} else if w.ansi {
28-
w.ansiseq.WriteRune(c)
28+
_, _ = w.ansiseq.WriteRune(c)
2929
if (c >= 0x41 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a) {
3030
// ANSI sequence terminated
3131
w.ansi = false

wordwrap/wordwrap.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func NewWriter(limit int) *WordWrap {
4646
func Bytes(b []byte, limit int) []byte {
4747
f := NewWriter(limit)
4848
_, _ = f.Write(b)
49-
f.Close()
49+
_ = f.Close()
5050

5151
return f.Bytes()
5252
}
@@ -59,21 +59,21 @@ func String(s string, limit int) string {
5959

6060
func (w *WordWrap) addSpace() {
6161
w.lineLen += w.space.Len()
62-
w.buf.Write(w.space.Bytes())
62+
_, _ = w.buf.Write(w.space.Bytes())
6363
w.space.Reset()
6464
}
6565

6666
func (w *WordWrap) addWord() {
6767
if w.word.Len() > 0 {
6868
w.addSpace()
6969
w.lineLen += w.word.PrintableRuneWidth()
70-
w.buf.Write(w.word.Bytes())
70+
_, _ = w.buf.Write(w.word.Bytes())
7171
w.word.Reset()
7272
}
7373
}
7474

7575
func (w *WordWrap) addNewLine() {
76-
w.buf.WriteRune('\n')
76+
_, _ = w.buf.WriteRune('\n')
7777
w.lineLen = 0
7878
w.space.Reset()
7979
}
@@ -101,10 +101,10 @@ func (w *WordWrap) Write(b []byte) (int, error) {
101101
for _, c := range s {
102102
if c == '\x1B' {
103103
// ANSI escape sequence
104-
w.word.WriteRune(c)
104+
_, _ = w.word.WriteRune(c)
105105
w.ansi = true
106106
} else if w.ansi {
107-
w.word.WriteRune(c)
107+
_, _ = w.word.WriteRune(c)
108108
if (c >= 0x40 && c <= 0x5a) || (c >= 0x61 && c <= 0x7a) {
109109
// ANSI sequence terminated
110110
w.ansi = false
@@ -117,7 +117,7 @@ func (w *WordWrap) Write(b []byte) (int, error) {
117117
w.lineLen = 0
118118
} else {
119119
// preserve whitespace
120-
w.buf.Write(w.space.Bytes())
120+
_, _ = w.buf.Write(w.space.Bytes())
121121
}
122122
w.space.Reset()
123123
}
@@ -127,15 +127,15 @@ func (w *WordWrap) Write(b []byte) (int, error) {
127127
} else if unicode.IsSpace(c) {
128128
// end of current word
129129
w.addWord()
130-
w.space.WriteRune(c)
130+
_, _ = w.space.WriteRune(c)
131131
} else if inGroup(w.Breakpoints, c) {
132132
// valid breakpoint
133133
w.addSpace()
134134
w.addWord()
135-
w.buf.WriteRune(c)
135+
_, _ = w.buf.WriteRune(c)
136136
} else {
137137
// any other character
138-
w.word.WriteRune(c)
138+
_, _ = w.word.WriteRune(c)
139139

140140
// add a line break if the current word would exceed the line's
141141
// character limit

0 commit comments

Comments
 (0)