Browse Source

move ioutil.ReadAll() call into if stmt scope

Kale Blankenship 8 years ago
parent
commit
f3e6640e1c
2 changed files with 2 additions and 4 deletions
  1. 1
    2
      internal/driver/fetch.go
  2. 1
    2
      internal/symbolizer/symbolizer.go

+ 1
- 2
internal/driver/fetch.go View File

403
 func statusCodeError(resp *http.Response) error {
403
 func statusCodeError(resp *http.Response) error {
404
 	if resp.Header.Get("X-Go-Pprof") != "" && strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {
404
 	if resp.Header.Get("X-Go-Pprof") != "" && strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {
405
 		// error is from pprof endpoint
405
 		// error is from pprof endpoint
406
-		body, err := ioutil.ReadAll(resp.Body)
407
-		if err == nil {
406
+		if body, err := ioutil.ReadAll(resp.Body); err == nil {
408
 			return fmt.Errorf("server response: %s - %s", resp.Status, body)
407
 			return fmt.Errorf("server response: %s - %s", resp.Status, body)
409
 		}
408
 		}
410
 	}
409
 	}

+ 1
- 2
internal/symbolizer/symbolizer.go View File

104
 func statusCodeError(resp *http.Response) error {
104
 func statusCodeError(resp *http.Response) error {
105
 	if resp.Header.Get("X-Go-Pprof") != "" && strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {
105
 	if resp.Header.Get("X-Go-Pprof") != "" && strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {
106
 		// error is from pprof endpoint
106
 		// error is from pprof endpoint
107
-		body, err := ioutil.ReadAll(resp.Body)
108
-		if err == nil {
107
+		if body, err := ioutil.ReadAll(resp.Body); err == nil {
109
 			return fmt.Errorf("server response: %s - %s", resp.Status, body)
108
 			return fmt.Errorf("server response: %s - %s", resp.Status, body)
110
 		}
109
 		}
111
 	}
110
 	}