Skip to content

Commit 071a995

Browse files
committed
cmd: address errcheck warnings
The following ones: internal/storage/redis/redis.go:106:14: Error return value of `s.conn.Send` is not checked (errcheck) s.conn.Send("LPUSH", s.redisKey, seriesToFlush) ^ internal/healthz/healthz.go:25:9: Error return value of `w.Write` is not checked (errcheck) w.Write([]byte("ok")) ^ internal/api/handler.go:132:9: Error return value of `w.Write` is not checked (errcheck) w.Write(out) ^ internal/storage/bigquery/client/example/example.go:43:17: Error return value of `c.PrintDatasets` is not checked (errcheck) c.PrintDatasets() ^ cadvisor.go:105:10: Error return value of `flag.Set` is not checked (errcheck) flag.Set("v", "2") ^ Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 60eba7b commit 071a995

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

cmd/cadvisor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func init() {
102102
flag.Var(&enableMetrics, "enable_metrics", fmt.Sprintf("comma-separated list of `metrics` to be enabled. If set, overrides 'disable_metrics'. Options are %s.", optstr))
103103

104104
// Default logging verbosity to V(2)
105-
flag.Set("v", "2")
105+
_ = flag.Set("v", "2")
106106
}
107107

108108
func main() {

cmd/internal/api/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ func writeResult(res interface{}, w http.ResponseWriter) error {
129129
}
130130

131131
w.Header().Set("Content-Type", "application/json")
132-
w.Write(out)
133-
return nil
132+
_, err = w.Write(out)
133+
return err
134134

135135
}
136136

cmd/internal/healthz/healthz.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
func handleHealthz(w http.ResponseWriter, r *http.Request) {
2424
w.WriteHeader(http.StatusOK)
25-
w.Write([]byte("ok"))
25+
_, _ = w.Write([]byte("ok"))
2626
}
2727

2828
// Register simple HTTP /healthz handler to return "ok".

cmd/internal/storage/bigquery/client/example/example.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ func main() {
4040
panic(err)
4141
}
4242

43-
c.PrintDatasets()
43+
err = c.PrintDatasets()
44+
if err != nil {
45+
panic(err)
46+
}
4447

4548
// Create a new dataset.
4649
err = c.CreateDataset("sampledataset")

cmd/internal/storage/redis/redis.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ func (s *redisStorage) AddStats(cInfo *info.ContainerInfo, stats *info.Container
101101
s.lastWrite = time.Now()
102102
}
103103
}()
104-
if len(seriesToFlush) > 0 {
105-
// We use redis's "LPUSH" to push the data to the redis
106-
s.conn.Send("LPUSH", s.redisKey, seriesToFlush)
104+
if len(seriesToFlush) == 0 {
105+
return nil
107106
}
108-
return nil
107+
// We use redis's "LPUSH" to push the data to the redis
108+
return s.conn.Send("LPUSH", s.redisKey, seriesToFlush)
109109
}
110110

111111
func (s *redisStorage) Close() error {

0 commit comments

Comments
 (0)