Remove deprecated libraries in app.go

This commit is contained in:
2026-02-16 09:00:23 -05:00
parent faf27839e7
commit c522b4c3ac

View File

@@ -3,8 +3,8 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "io"
"math/rand" "math/rand/v2"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
@@ -123,7 +123,7 @@ func (a *App) getTopicDetails(w http.ResponseWriter, r *http.Request) {
} }
defer res.Body.Close() defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body) body, err := io.ReadAll(res.Body)
if err != nil { if err != nil {
log.Warn().Msgf("could not read response body: %s\n", err) log.Warn().Msgf("could not read response body: %s\n", err)
respondWithJSON(w, http.StatusInternalServerError, map[string]string{"error": "Failed to read response"}) respondWithJSON(w, http.StatusInternalServerError, map[string]string{"error": "Failed to read response"})
@@ -188,8 +188,7 @@ func (a *App) refreshTopics() {
} }
a.LastRefresh = time.Now() a.LastRefresh = time.Now()
rand.Seed(time.Now().UnixNano()) time.Sleep(time.Duration(rand.IntN(90-60+1)+60) * time.Second)
time.Sleep(time.Duration(rand.Intn(90-60+1)+60) * time.Second)
} }
} }
@@ -262,7 +261,7 @@ func (a *App) getDeals(id int, firstPage int, lastPage int) []Topic {
if err != nil { if err != nil {
log.Warn().Msgf("error fetching deals: %s\n", err) log.Warn().Msgf("error fetching deals: %s\n", err)
} }
body, err := ioutil.ReadAll(res.Body) body, err := io.ReadAll(res.Body)
if err != nil { if err != nil {
log.Warn().Msgf("could not read response body: %s\n", err) log.Warn().Msgf("could not read response body: %s\n", err)
} }
@@ -292,7 +291,7 @@ func (a *App) getRedirects() []Redirect {
if err != nil { if err != nil {
log.Warn().Msgf("error fetching redirects: %s\n", err) log.Warn().Msgf("error fetching redirects: %s\n", err)
} }
body, err := ioutil.ReadAll(res.Body) body, err := io.ReadAll(res.Body)
if err != nil { if err != nil {
log.Warn().Msgf("could not read response body: %s\n", err) log.Warn().Msgf("could not read response body: %s\n", err)
} }