Skip to content

Commit

Permalink
Merge pull request #1556 from Khaalid-oh/fix/ioutil
Browse files Browse the repository at this point in the history
Change all deprecated ioutil.ReadAll to io.ReadAll
  • Loading branch information
elraphty authored Feb 23, 2024
2 parents 204eb81 + e462011 commit 04d81a7
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 27 deletions.
6 changes: 3 additions & 3 deletions db/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"strconv"
"time"
Expand Down Expand Up @@ -175,7 +175,7 @@ func Verify(w http.ResponseWriter, r *http.Request) {
}

payload := VerifyPayload{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
err = json.Unmarshal(body, &payload)
if err != nil {
Expand Down Expand Up @@ -263,7 +263,7 @@ type Save struct {
func PostSave(w http.ResponseWriter, r *http.Request) {

save := Save{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
err = json.Unmarshal(body, &save)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions feeds/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package feeds

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"strings"
)
Expand Down Expand Up @@ -161,6 +161,6 @@ func httpget(url string) ([]byte, error) {
}
defer response.Body.Close()

body, _ := ioutil.ReadAll(response.Body)
body, _ := io.ReadAll(response.Body)
return body, nil
}
8 changes: 4 additions & 4 deletions feeds/podcastindex.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strconv"
Expand Down Expand Up @@ -122,7 +122,7 @@ func PodcastFeed(url string, fulltext bool) (*Podcast, error) {
defer resp.Body.Close()

var r PodcastResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("=> json unmarshall error", err)
Expand Down Expand Up @@ -158,7 +158,7 @@ func PodcastEpisodes(url string, fulltext bool) ([]Episode, error) {
defer resp.Body.Close()

var r EpisodeResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand Down Expand Up @@ -234,7 +234,7 @@ func PodcastEpisodesByPerson(query string, fulltext bool) ([]Episode, error) {
defer resp.Body.Close()

var r EpisodeResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand Down
4 changes: 2 additions & 2 deletions handlers/bots.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handlers
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"regexp"
"strconv"
Expand All @@ -20,7 +20,7 @@ func CreateOrEditBot(w http.ResponseWriter, r *http.Request) {
pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string)

bot := db.Bot{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
err = json.Unmarshal(body, &bot)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions handlers/bounties.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handlers
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"reflect"
Expand Down Expand Up @@ -46,7 +46,7 @@ func GetBountiesLeaderboard(w http.ResponseWriter, _ *http.Request) {

func DeleteBountyAssignee(w http.ResponseWriter, r *http.Request) {
invoice := db.DeleteBountyAssignee{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
var deletedAssignee bool

r.Body.Close()
Expand Down
4 changes: 2 additions & 2 deletions handlers/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package handlers
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"strconv"

Expand Down Expand Up @@ -56,7 +56,7 @@ func CreateChannel(w http.ResponseWriter, r *http.Request) {
pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string)

channel := db.Channel{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
err = json.Unmarshal(body, &channel)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions handlers/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -53,7 +53,7 @@ func DownloadYoutubeFeed(w http.ResponseWriter, r *http.Request) {
tube, err := youtube.NewService(ctx, option.WithAPIKey(apiKey))

youtube_download := db.YoutubeDownload{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)

r.Body.Close()
err = json.Unmarshal(body, &youtube_download)
Expand Down Expand Up @@ -143,7 +143,7 @@ func processYoutubeDownload(data []string) {
fmt.Println("Youtube Download Request Error ===", err)
}
defer response.Body.Close()
res, err := ioutil.ReadAll(response.Body)
res, err := io.ReadAll(response.Body)
if err != nil {
fmt.Println("Youtube Download Request Error ==", err)
}
Expand Down Expand Up @@ -272,7 +272,7 @@ func getFeed(feedURL string, feedID string) (*feeds.Podcast, error) {
defer resp.Body.Close()

var r feeds.PodcastResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand Down Expand Up @@ -314,7 +314,7 @@ func getEpisodes(feedURL string, feedID string) ([]feeds.Episode, error) {
defer resp.Body.Close()

var r feeds.EpisodeResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand Down Expand Up @@ -348,7 +348,7 @@ func searchPodcastIndex(term string) ([]feeds.Podcast, error) {
defer resp.Body.Close()

var r feeds.PodcastSearchResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand Down
7 changes: 3 additions & 4 deletions handlers/people.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -479,7 +478,7 @@ func GetAssetByPubkey(pubkey string) ([]db.AssetBalanceData, error) {
defer resp.Body.Close()

var r db.AssetResponse
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand Down Expand Up @@ -512,7 +511,7 @@ func GetAssetList(pubkey string) ([]db.AssetListData, error) {
defer resp.Body.Close()

var r []db.AssetListData
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
err = json.Unmarshal(body, &r)
if err != nil {
fmt.Println("json unmarshall error", err)
Expand All @@ -527,7 +526,7 @@ func AddOrRemoveBadge(w http.ResponseWriter, r *http.Request) {
pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string)

badgeCreationData := db.BadgeCreationData{}
body, err := ioutil.ReadAll(r.Body)
body, err := io.ReadAll(r.Body)
r.Body.Close()
err = json.Unmarshal(body, &badgeCreationData)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions routes/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package routes
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"os"
"time"
Expand Down Expand Up @@ -116,7 +116,7 @@ func getFromAuth(path string) (*extractResponse, error) {
return nil, err
}
defer resp.Body.Close()
body2, err := ioutil.ReadAll(resp.Body)
body2, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 04d81a7

Please sign in to comment.