diff --git a/cmd/promtool/http.go b/cmd/promtool/http.go index 43656ad67..e269a23ed 100644 --- a/cmd/promtool/http.go +++ b/cmd/promtool/http.go @@ -14,8 +14,6 @@ package main import ( - "context" - "net/http" "time" "github.com/pkg/errors" @@ -42,12 +40,6 @@ func newPrometheusHTTPClient(serverURL string) (*prometheusHTTPClient, error) { }, nil } -func (c *prometheusHTTPClient) do(req *http.Request) (*http.Response, []byte, error) { - ctx, cancel := context.WithTimeout(context.Background(), c.requestTimeout) - defer cancel() - return c.httpClient.Do(ctx, req) -} - func (c *prometheusHTTPClient) urlJoin(path string) string { return c.httpClient.URL(path, nil).String() } diff --git a/discovery/openstack/mock_test.go b/discovery/openstack/mock_test.go index 67b14f6f6..13c25dfbb 100644 --- a/discovery/openstack/mock_test.go +++ b/discovery/openstack/mock_test.go @@ -247,7 +247,7 @@ func (m *SDMock) HandleHypervisorListSuccessfully() { testHeader(m.t, r, "X-Auth-Token", tokenID) w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, hypervisorListBody) + fmt.Fprint(w, hypervisorListBody) }) } @@ -544,7 +544,7 @@ func (m *SDMock) HandleServerListSuccessfully() { testHeader(m.t, r, "X-Auth-Token", tokenID) w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, serverListBody) + fmt.Fprint(w, serverListBody) }) } @@ -583,6 +583,6 @@ func (m *SDMock) HandleFloatingIPListSuccessfully() { testHeader(m.t, r, "X-Auth-Token", tokenID) w.Header().Add("Content-Type", "application/json") - fmt.Fprintf(w, listOutput) + fmt.Fprint(w, listOutput) }) } diff --git a/promql/parse.go b/promql/parse.go index 2a055fbbb..4bb4a11c6 100644 --- a/promql/parse.go +++ b/promql/parse.go @@ -326,17 +326,15 @@ var errUnexpected = errors.New("unexpected error") // recover is the handler that turns panics into returns from the top level of Parse. func (p *parser) recover(errp *error) { e := recover() - if e != nil { - if _, ok := e.(runtime.Error); ok { - // Print the stack trace but do not inhibit the running application. - buf := make([]byte, 64<<10) - buf = buf[:runtime.Stack(buf, false)] - - fmt.Fprintf(os.Stderr, "parser panic: %v\n%s", e, buf) - *errp = errUnexpected - } else { - *errp = e.(error) - } + if _, ok := e.(runtime.Error); ok { + // Print the stack trace but do not inhibit the running application. + buf := make([]byte, 64<<10) + buf = buf[:runtime.Stack(buf, false)] + + fmt.Fprintf(os.Stderr, "parser panic: %v\n%s", e, buf) + *errp = errUnexpected + } else if e != nil { + *errp = e.(error) } p.lex.close() } diff --git a/web/federate_test.go b/web/federate_test.go index 03c4763eb..1476bec3f 100644 --- a/web/federate_test.go +++ b/web/federate_test.go @@ -28,7 +28,6 @@ import ( var scenarios = map[string]struct { params string - accept string externalLabels labels.Labels code int body string