Skip to content

Commit cd20a38

Browse files
committed
😄 show error when not ok
1 parent b08ad80 commit cd20a38

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

lib/api.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"net/http"
8+
"os"
99
)
1010

1111
const apiURL = "https://api.godoc.org/search?q="
@@ -20,7 +20,6 @@ type Package struct {
2020
Score float64 `json:"score,omitempty"`
2121
}
2222

23-
2423
type Response struct {
2524
Results []Package `json:"results"`
2625
}
@@ -34,7 +33,7 @@ func doSearch(pkg string) ([]Package, error) {
3433
defer resp.Body.Close()
3534

3635
if resp.StatusCode != http.StatusOK {
37-
io.Copy(ioutil.Discard, resp.Body)
36+
io.Copy(os.Stderr, resp.Body)
3837
return nil, fmt.Errorf("failed to search package, server return code=%s", resp.Status)
3938
}
4039
var res Response

0 commit comments

Comments
 (0)