Skip to content

Commit

Permalink
chore: remove refs to deprecated io/ioutil (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
testwill committed Dec 10, 2023
1 parent d5fc743 commit 2fbf3e9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions backends/caiyun.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"strconv"
Expand Down Expand Up @@ -93,7 +93,7 @@ func (c *CaiyunConfig) GetWeatherDataFromLocalBegin(lng float64, lat float64, nu
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func (c *CaiyunConfig) GetWeatherDataFromLocalBegin(lng float64, lat float64, nu
return nil, err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions backends/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package backends

import (
"encoding/json"
"io/ioutil"
"os"
"log"

"github.com/schachmat/wego/iface"
Expand All @@ -19,7 +19,7 @@ func (c *jsnConfig) Setup() {
// to further limit the amount of days in the output. It obviously cannot
// produce more data than is available in the file.
func (c *jsnConfig) Fetch(loc string, numdays int) (ret iface.Data) {
b, err := ioutil.ReadFile(loc)
b, err := os.ReadFile(loc)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions backends/openweathermap.org.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"flag"
"fmt"
"github.com/schachmat/wego/iface"
"io/ioutil"
"io"
"log"
"net/http"
"regexp"
Expand Down Expand Up @@ -70,7 +70,7 @@ func (c *openWeatherConfig) fetch(url string) (*openWeatherResponse, error) {
return nil, fmt.Errorf(" Unable to get (%s) %v", url, err)
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, fmt.Errorf("Unable to read response body (%s): %v", url, err)
}
Expand Down
6 changes: 3 additions & 3 deletions backends/smhi.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/schachmat/wego/iface"
"io/ioutil"
"io"
"log"
"net/http"
"regexp"
Expand Down Expand Up @@ -89,7 +89,7 @@ func (c *smhiConfig) fetch(url string) (*smhiResponse, error) {
if err != nil {
return nil, fmt.Errorf("Unable to get (%s): %v", url, err)
} else if resp.StatusCode != 200 {
body, _ := ioutil.ReadAll(resp.Body)
body, _ := io.ReadAll(resp.Body)
quip := ""
if string(body) == "Requested point is out of bounds" {
quip = "\nPlease note that SMHI only service the nordic countries."
Expand All @@ -98,7 +98,7 @@ func (c *smhiConfig) fetch(url string) (*smhiResponse, error) {
}
defer resp.Body.Close()

body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Unable to read response body (%s): %v", url, err)
}
Expand Down
6 changes: 3 additions & 3 deletions backends/worldweatheronline.com.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"flag"
"io/ioutil"
"io"
"log"
"net/http"
"net/url"
Expand Down Expand Up @@ -268,7 +268,7 @@ func (c *wwoConfig) getCoordinatesFromAPI(queryParams []string, res chan *iface.
}
defer hres.Body.Close()

body, err := ioutil.ReadAll(hres.Body)
body, err := io.ReadAll(hres.Body)
if err != nil {
log.Println("Unable to read geo location data:", err)
res <- nil
Expand Down Expand Up @@ -329,7 +329,7 @@ func (c *wwoConfig) Fetch(loc string, numdays int) iface.Data {
}
defer res.Body.Close()

body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 2fbf3e9

Please sign in to comment.