meta: refactor repository
This commit is contained in:
parent
a306e192a4
commit
599fe1903f
28 changed files with 276 additions and 136 deletions
|
@ -29,14 +29,14 @@ func GetResponse() (*http.Response, error) {
|
|||
for attempts != 0 {
|
||||
res, err = http.Get(url)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Error encountered... trying again...")
|
||||
fmt.Fprintln(os.Stderr, "error encountered... trying again")
|
||||
time.Sleep(2 * time.Second)
|
||||
attempts--
|
||||
continue
|
||||
}
|
||||
|
||||
if res.StatusCode != 200 {
|
||||
fmt.Fprintf(os.Stderr, "API returned but a 200, so I will be running this again in a few seconds.")
|
||||
fmt.Fprintf(os.Stderr, "the API returned but a 200, so I will be running this again in a few seconds")
|
||||
time.Sleep(2 * time.Second)
|
||||
attempts--
|
||||
continue
|
||||
|
@ -52,7 +52,7 @@ func GetResponse() (*http.Response, error) {
|
|||
}
|
||||
|
||||
if res.StatusCode != 200 {
|
||||
return nil, errors.New("Gave up attempting to get 200.")
|
||||
return nil, errors.New("gave up attempting to get 200")
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
@ -73,10 +73,8 @@ func GetBodyFromResponse(res *http.Response) ([]byte, error) {
|
|||
|
||||
func NewQuoteFromBody(body []byte) (Quote, error) {
|
||||
var quote Quote
|
||||
var err error
|
||||
|
||||
err = json.Unmarshal(body, "e)
|
||||
if err != nil {
|
||||
|
||||
if err := json.Unmarshal(body, "e); err != nil {
|
||||
return Quote{}, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue