Fix up ignored/inefficient assigns (via ineffassign linter)

This commit is contained in:
Jimmi Dyson 2015-11-27 22:01:54 +00:00
parent b5d8d0c991
commit b9ff5c098c
7 changed files with 17 additions and 10 deletions

View File

@ -160,9 +160,9 @@ func (self *Client) httpGetJsonData(data, postData interface{}, url, infoName st
var err error
if postData != nil {
data, err := json.Marshal(postData)
if err != nil {
return fmt.Errorf("unable to marshal data: %v", err)
data, marshalErr := json.Marshal(postData)
if marshalErr != nil {
return fmt.Errorf("unable to marshal data: %v", marshalErr)
}
resp, err = http.Post(url, "application/json", bytes.NewBuffer(data))
} else {

View File

@ -92,16 +92,16 @@ func (self *Client) httpGetResponse(postData interface{}, url, infoName string)
var err error
if postData != nil {
data, err := json.Marshal(postData)
if err != nil {
return nil, fmt.Errorf("unable to marshal data: %v", err)
data, marshalErr := json.Marshal(postData)
if marshalErr != nil {
return nil, fmt.Errorf("unable to marshal data: %v", marshalErr)
}
resp, err = http.Post(url, "application/json", bytes.NewBuffer(data))
} else {
resp, err = http.Get(url)
}
if err != nil {
return nil, fmt.Errorf("unable to get %q from %q: %v", infoName, url, err)
return nil, fmt.Errorf("unable to post %q to %q: %v", infoName, url, err)
}
if resp == nil {
return nil, fmt.Errorf("received empty response for %q from %q", infoName, url)

View File

@ -33,6 +33,9 @@ func TestHealthzOk(t *testing.T) {
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
t.Fatal(err)
}
if string(body) != "ok" {
t.Fatalf("cAdvisor returned unexpected healthz status of %q", body)

View File

@ -443,6 +443,9 @@ func (c *containerData) updateSpec() error {
}
customMetrics, err := c.collectorManager.GetSpec()
if err != nil {
return err
}
if len(customMetrics) > 0 {
spec.HasCustomMetrics = true
spec.CustomMetrics = customMetrics

View File

@ -1195,7 +1195,10 @@ func (m *manager) DockerInfo() (DockerStatus, error) {
}
if val, ok := info["DriverStatus"]; ok {
var driverStatus [][]string
err = json.Unmarshal([]byte(val), &driverStatus)
err := json.Unmarshal([]byte(val), &driverStatus)
if err != nil {
return DockerStatus{}, err
}
out.DriverStatus = make(map[string]string)
for _, v := range driverStatus {
if len(v) == 2 {

View File

@ -79,7 +79,6 @@ func (self *redisStorage) AddStats(ref info.ContainerReference, stats *info.Cont
b, _ := json.Marshal(detail)
if self.readyToFlush() {
seriesToFlush = b
b = nil
self.lastWrite = time.Now()
}
}()

View File

@ -155,7 +155,6 @@ func (self *OomParser) StreamOoms(outStream chan *OomInstance) {
}
line = <-lineChannel
}
in_oom_kernel_log = false
outStream <- oomCurrentInstance
}
}