summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorguangwu <guoguangwu@magic-shield.com>2023-12-11 04:13:16 +0800
committerGitHub <noreply@github.com>2023-12-10 21:13:16 +0100
commit2fbf3e908e8b00249d99b6fe16e1f0917cb5d59e (patch)
tree5664364c71d54fd0543e050edd1ef30eb1dcc0b2
parentd5fc7432ee39021328e637a703dfa2bb73c8ec10 (diff)
chore: remove refs to deprecated io/ioutil (#169)
-rw-r--r--backends/caiyun.go6
-rw-r--r--backends/json.go4
-rw-r--r--backends/openweathermap.org.go4
-rw-r--r--backends/smhi.go6
-rw-r--r--backends/worldweatheronline.com.go6
5 files changed, 13 insertions, 13 deletions
diff --git a/backends/caiyun.go b/backends/caiyun.go
index 83e0af3..5ab3550 100644
--- a/backends/caiyun.go
+++ b/backends/caiyun.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"flag"
"fmt"
- "io/ioutil"
+ "io"
"log"
"net/http"
"strconv"
@@ -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
}
@@ -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
}
diff --git a/backends/json.go b/backends/json.go
index 9460d48..28dff83 100644
--- a/backends/json.go
+++ b/backends/json.go
@@ -2,7 +2,7 @@ package backends
import (
"encoding/json"
- "io/ioutil"
+ "os"
"log"
"github.com/schachmat/wego/iface"
@@ -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)
}
diff --git a/backends/openweathermap.org.go b/backends/openweathermap.org.go
index 9e80ef6..d887013 100644
--- a/backends/openweathermap.org.go
+++ b/backends/openweathermap.org.go
@@ -5,7 +5,7 @@ import (
"flag"
"fmt"
"github.com/schachmat/wego/iface"
- "io/ioutil"
+ "io"
"log"
"net/http"
"regexp"
@@ -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)
}
diff --git a/backends/smhi.go b/backends/smhi.go
index af24e9e..733ff12 100644
--- a/backends/smhi.go
+++ b/backends/smhi.go
@@ -4,7 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/schachmat/wego/iface"
- "io/ioutil"
+ "io"
"log"
"net/http"
"regexp"
@@ -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."
@@ -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)
}
diff --git a/backends/worldweatheronline.com.go b/backends/worldweatheronline.com.go
index 80a4187..ef1f20f 100644
--- a/backends/worldweatheronline.com.go
+++ b/backends/worldweatheronline.com.go
@@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"flag"
- "io/ioutil"
+ "io"
"log"
"net/http"
"net/url"
@@ -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
@@ -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)
}