meta: refactor repository

This commit is contained in:
Artur Manuel 2025-03-26 15:08:13 +00:00
commit 599fe1903f
Signed by: amadaluzia
SSH key fingerprint: SHA256:Zwg7gBuZyaG48ucAZneJwltiXu0+tJb7c3lYt9AYlLg
28 changed files with 276 additions and 136 deletions

View file

@ -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, &quote)
if err != nil {
if err := json.Unmarshal(body, &quote); err != nil {
return Quote{}, err
}