refactor: Remove remaining uses of depreciated package io/ioutil (#837)

This commit is contained in:
Dave 2023-07-30 07:23:43 -04:00 committed by GitHub
parent 6151ea1c4d
commit 8e8d474ae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -8,7 +8,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
@ -45,7 +44,7 @@ func getModelStatus(url string) (response map[string]interface{}) {
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
fmt.Println("Error reading response body:", err) fmt.Println("Error reading response body:", err)
return return
@ -97,7 +96,7 @@ func postModelApplyRequest(url string, request modelApplyRequest) (response map[
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
fmt.Println("Error reading response body:", err) fmt.Println("Error reading response body:", err)
return return
@ -153,7 +152,7 @@ var _ = Describe("API test", func() {
} }
out, err := yaml.Marshal(g) out, err := yaml.Marshal(g)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(tmpdir, "gallery_simple.yaml"), out, 0644) err = os.WriteFile(filepath.Join(tmpdir, "gallery_simple.yaml"), out, 0644)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
galleries := []gallery.Gallery{ galleries := []gallery.Gallery{

View File

@ -4,7 +4,6 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -105,7 +104,7 @@ func ImageEndpoint(cm *config.ConfigLoader, o *options.Option) func(c *fiber.Ctx
tempDir = o.ImageDir tempDir = o.ImageDir
} }
// Create a temporary file // Create a temporary file
outputFile, err := ioutil.TempFile(tempDir, "b64") outputFile, err := os.CreateTemp(tempDir, "b64")
if err != nil { if err != nil {
return err return err
} }

View File

@ -1,7 +1,6 @@
package gallery_test package gallery_test
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -50,7 +49,7 @@ var _ = Describe("Model test", func() {
}} }}
out, err := yaml.Marshal(gallery) out, err := yaml.Marshal(gallery)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(tempdir, "gallery_simple.yaml"), out, 0644) err = os.WriteFile(filepath.Join(tempdir, "gallery_simple.yaml"), out, 0644)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
galleries := []Gallery{ galleries := []Gallery{