Skip to content

Commit 33e2e47

Browse files
committed
Fix up errcheck linting.
Signed-off-by: SuperQ <[email protected]>
1 parent edfed5c commit 33e2e47

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
linters-settings:
3+
errcheck:
4+
exclude: scripts/errcheck_excludes.txt

cmd/client/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ func (c *Coordinator) doPush(resp *http.Response, origRequest *http.Request, cli
166166
url := base.ResolveReference(u)
167167

168168
buf := &bytes.Buffer{}
169+
//nolint:errcheck // https://github.com/prometheus-community/PushProx/issues/111
169170
resp.Write(buf)
170171
request := &http.Request{
171172
Method: "POST",

cmd/proxy/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ func (h *httpHandler) handlePoll(w http.ResponseWriter, r *http.Request) {
150150
http.Error(w, fmt.Sprintf("Error WaitForScrapeInstruction: %s", err.Error()), 408)
151151
return
152152
}
153+
//nolint:errcheck // https://github.com/prometheus-community/PushProx/issues/111
153154
request.WriteProxy(w) // Send full request as the body of the response.
154155
level.Info(h.logger).Log("msg", "Responded to /poll", "url", request.URL.String(), "scrape_id", request.Header.Get("Id"))
155156
}
@@ -161,6 +162,7 @@ func (h *httpHandler) handleListClients(w http.ResponseWriter, r *http.Request)
161162
for _, k := range known {
162163
targets = append(targets, &targetGroup{Targets: []string{k}})
163164
}
165+
//nolint:errcheck // https://github.com/prometheus-community/PushProx/issues/111
164166
json.NewEncoder(w).Encode(targets)
165167
level.Info(h.logger).Log("msg", "Responded to /clients", "client_count", len(known))
166168
}

scripts/errcheck_excludes.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Don't flag lines such as "io.Copy(ioutil.Discard, resp.Body)".
2+
io.Copy
3+
// The next two are used in HTTP handlers, any error is handled by the server itself.
4+
io.WriteString
5+
(net/http.ResponseWriter).Write
6+
7+
// Never check for logger errors.
8+
(github.com/go-kit/kit/log.Logger).Log

0 commit comments

Comments
 (0)