Skip to content

Commit b9c5324

Browse files
committed
Fix some "error value not checked" linter warnings
Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 1313182 commit b9c5324

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

examples/journal/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func main() {
2929

3030
if ok {
3131
// use journal native protocol
32-
journal.Send("this is a message logged through the native protocol", journal.PriInfo, nil)
32+
_ = journal.Send("this is a message logged through the native protocol", journal.PriInfo, nil)
3333
} else {
3434
// use stderr
3535
fmt.Fprintln(os.Stderr, "this is a message logged through stderr")

journal/journal_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func appendVariable(w io.Writer, name, value string) {
193193
* - the data, followed by a newline
194194
*/
195195
fmt.Fprintln(w, name)
196-
binary.Write(w, binary.LittleEndian, uint64(len(value)))
196+
_ = binary.Write(w, binary.LittleEndian, uint64(len(value)))
197197
fmt.Fprintln(w, value)
198198
} else {
199199
/* just write the variable and value all on one line */

journal/journal_unix_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func ExampleStderrIsJournalStream() {
135135

136136
if ok {
137137
// use journal native protocol
138-
journal.Send("this is a message logged through the native protocol", journal.PriInfo, nil)
138+
_ = journal.Send("this is a message logged through the native protocol", journal.PriInfo, nil)
139139
} else {
140140
// use stderr
141141
fmt.Fprintln(os.Stderr, "this is a message logged through stderr")

sdjournal/journal_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,10 @@ func TestJournalWait(t *testing.T) {
126126
t.Errorf("Wait did not wait 300ms. Actually waited %s", duration.String())
127127
}
128128

129-
journal.Send("test message", journal.PriInfo, map[string]string{"TEST": "TestJournalWait " + id})
129+
err := journal.Send("test message", journal.PriInfo, map[string]string{"TEST": "TestJournalWait " + id})
130+
if err != nil {
131+
t.Fatal(err)
132+
}
130133
for ret := -1; ret != SD_JOURNAL_APPEND; {
131134
t1 = time.Now()
132135
ret = j.Wait(time.Millisecond * 300)

unit/deserialize.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ const (
3838
SYSTEMD_NEWLINE = "\r\n"
3939
)
4040

41-
var (
42-
// ErrLineTooLong gets returned when a line is too long for systemd to handle.
43-
ErrLineTooLong = fmt.Errorf("line too long (max %d bytes)", SYSTEMD_LINE_MAX)
44-
)
41+
// ErrLineTooLong gets returned when a line is too long for systemd to handle.
42+
var ErrLineTooLong = fmt.Errorf("line too long (max %d bytes)", SYSTEMD_LINE_MAX)
4543

4644
// DeserializeOptions parses a systemd unit file into a list of UnitOptions
4745
func DeserializeOptions(f io.Reader) (opts []*UnitOption, err error) {
@@ -79,7 +77,6 @@ type lexData struct {
7977

8078
// deserializeAll deserializes into UnitSections and UnitOptions.
8179
func deserializeAll(f io.Reader) ([]*UnitSection, []*UnitOption, error) {
82-
8380
lexer, lexchan, errchan := newLexer(f)
8481

8582
go lexer.lex()
@@ -255,7 +252,7 @@ func (l *lexer) lexNextSectionOrOptionFunc(section string) lexStep {
255252
return l.ignoreLineFunc(l.lexNextSectionOrOptionFunc(section)), nil
256253
}
257254

258-
l.buf.UnreadRune()
255+
_ = l.buf.UnreadRune() // This can't fail as we just called ReadRune.
259256
return l.lexOptionNameFunc(section), nil
260257
}
261258
}

0 commit comments

Comments
 (0)