mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Handle ioutil deprecations (#53526)
* replace ioutil.ReadFile -> os.ReadFile * replace ioutil.ReadAll -> io.ReadAll * replace ioutil.TempFile -> os.CreateTemp * replace ioutil.NopCloser -> io.NopCloser * replace ioutil.WriteFile -> os.WriteFile * replace ioutil.TempDir -> os.MkdirTemp * replace ioutil.Discard -> io.Discard
This commit is contained in:
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -62,7 +62,7 @@ func (getHTTPContents) getContents(url string) (string, error) {
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
all, err := ioutil.ReadAll(response.Body)
|
||||
all, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
@@ -276,7 +276,7 @@ func (p *publisher) postRequest(url string, obj interface{}, desc string) error
|
||||
|
||||
if res.Body != nil {
|
||||
defer res.Body.Close()
|
||||
body, err := ioutil.ReadAll(res.Body)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package main
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/getkin/kin-openapi/openapi2"
|
||||
"github.com/getkin/kin-openapi/openapi2conv"
|
||||
"github.com/getkin/kin-openapi/openapi3"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
)
|
||||
|
||||
// main This simple script will take the swagger v2 spec generated by grafana and convert them into openapi 3
|
||||
@@ -30,7 +30,7 @@ func main() {
|
||||
}
|
||||
|
||||
fmt.Printf("Reading swagger 2 file %s\n", inFile)
|
||||
byt, err := ioutil.ReadFile(inFile)
|
||||
byt, err := os.ReadFile(inFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -54,7 +54,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err = ioutil.WriteFile(outFile, j3, 0644); err != nil {
|
||||
if err = os.WriteFile(outFile, j3, 0644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Printf("OpenAPI specs generated in file %s\n", outFile)
|
||||
|
||||
Reference in New Issue
Block a user