Fix staticcheck errors

Not sure why they only show up now.

Signed-off-by: Bjoern Rabenstein <bjoern@rabenste.in>
This commit is contained in:
Bjoern Rabenstein 2019-04-15 19:06:25 +02:00
parent 335a34486e
commit a92ef68dd8
4 changed files with 11 additions and 22 deletions

View file

@ -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()
}

View file

@ -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)
})
}

View file

@ -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)]
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)
}
fmt.Fprintf(os.Stderr, "parser panic: %v\n%s", e, buf)
*errp = errUnexpected
} else if e != nil {
*errp = e.(error)
}
p.lex.close()
}

View file

@ -28,7 +28,6 @@ import (
var scenarios = map[string]struct {
params string
accept string
externalLabels labels.Labels
code int
body string