remove deprecated ioutil functions

This commit is contained in:
Louis Abel 2024-06-10 08:31:26 -07:00
parent 18f9f5c77c
commit 04bd3b64a6
Signed by: label
GPG Key ID: 3331F061D1D9990E
10 changed files with 21 additions and 23 deletions

View File

@ -22,7 +22,7 @@ package file
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"path/filepath" "path/filepath"
) )
@ -65,7 +65,7 @@ func (f *File) Read(path string) ([]byte, error) {
return nil, err return nil, err
} }
body, err := ioutil.ReadAll(r) body, err := io.ReadAll(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -23,7 +23,7 @@ package gcs
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"cloud.google.com/go/storage" "cloud.google.com/go/storage"
) )
@ -71,7 +71,7 @@ func (g *GCS) Read(path string) ([]byte, error) {
return nil, err return nil, err
} }
body, err := ioutil.ReadAll(r) body, err := io.ReadAll(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -22,7 +22,7 @@ package s3
import ( import (
"bytes" "bytes"
"io/ioutil" "io"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/awserr"
@ -99,7 +99,7 @@ func (s *S3) Read(path string) ([]byte, error) {
return nil, nil return nil, nil
} }
body, err := ioutil.ReadAll(obj.Body) body, err := io.ReadAll(obj.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -23,7 +23,7 @@ package directives
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"path/filepath" "path/filepath"
@ -55,7 +55,7 @@ func add(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, patchTree
return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FROM:%s", addType.File)) return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FROM:%s", addType.File))
} }
replacingBytes, err = ioutil.ReadAll(fPatch) replacingBytes, err = io.ReadAll(fPatch)
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_READ_FROM:%s", addType.File)) return errors.New(fmt.Sprintf("COULD_NOT_READ_FROM:%s", addType.File))
} }

View File

@ -27,7 +27,7 @@ import (
"crypto/sha256" "crypto/sha256"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"path/filepath" "path/filepath"
"time" "time"
@ -66,7 +66,7 @@ func lookaside(cfg *srpmprocpb.Cfg, _ *data.ProcessData, md *data.ModeData, patc
return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FILE:%s", path)) return errors.New(fmt.Sprintf("COULD_NOT_OPEN_FILE:%s", path))
} }
bts, err := ioutil.ReadAll(f) bts, err := io.ReadAll(f)
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_READ_FILE:%s", path)) return errors.New(fmt.Sprintf("COULD_NOT_READ_FILE:%s", path))
} }

View File

@ -23,7 +23,7 @@ package directives
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
@ -56,7 +56,7 @@ func replace(cfg *srpmprocpb.Cfg, pd *data.ProcessData, _ *data.ModeData, patchT
return errors.New(fmt.Sprintf("COULD_NOT_OPEN_REPLACING:%s", replacing.WithFile)) return errors.New(fmt.Sprintf("COULD_NOT_OPEN_REPLACING:%s", replacing.WithFile))
} }
replacingBytes, err := ioutil.ReadAll(fPatch) replacingBytes, err := io.ReadAll(fPatch)
if err != nil { if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_READ_REPLACING:%s", replacing.WithFile)) return errors.New(fmt.Sprintf("COULD_NOT_READ_REPLACING:%s", replacing.WithFile))
} }

View File

@ -23,7 +23,7 @@ package directives
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"math" "math"
"os" "os"
"path/filepath" "path/filepath"
@ -215,7 +215,7 @@ func specChange(cfg *srpmprocpb.Cfg, pd *data.ProcessData, md *data.ModeData, _
return errors.New("COULD_NOT_READ_SPEC_FILE") return errors.New("COULD_NOT_READ_SPEC_FILE")
} }
specBts, err := ioutil.ReadAll(specFile) specBts, err := io.ReadAll(specFile)
if err != nil { if err != nil {
return errors.New("COULD_NOT_READ_ALL_BYTES") return errors.New("COULD_NOT_READ_ALL_BYTES")
} }

View File

@ -23,7 +23,7 @@ package modes
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil" "io"
"log" "log"
"net/http" "net/http"
"path/filepath" "path/filepath"
@ -317,7 +317,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
return nil return nil
} }
fileBytes, err := ioutil.ReadAll(metadataFile) fileBytes, err := io.ReadAll(metadataFile)
if err != nil { if err != nil {
return fmt.Errorf("could not read metadata file: %v", err) return fmt.Errorf("could not read metadata file: %v", err)
} }
@ -427,7 +427,7 @@ func (g *GitMode) WriteSource(pd *data.ProcessData, md *data.ModeData) error {
} }
} }
body, err = ioutil.ReadAll(resp.Body) body, err = io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("could not read the whole dist-git file: %v", err) return fmt.Errorf("could not read the whole dist-git file: %v", err)
} }

View File

@ -4,7 +4,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"net/http" "net/http"
"path/filepath" "path/filepath"
@ -42,7 +41,7 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto
return fmt.Errorf("could not open metadata file: %v", err) return fmt.Errorf("could not open metadata file: %v", err)
} }
fileBytes, err := ioutil.ReadAll(metadataFile) fileBytes, err := io.ReadAll(metadataFile)
if err != nil { if err != nil {
return fmt.Errorf("could not read metadata file: %v", err) return fmt.Errorf("could not read metadata file: %v", err)
} }
@ -87,7 +86,7 @@ func Fetch(logger io.Writer, cdnUrl string, dir string, fs billy.Filesystem, sto
return fmt.Errorf("could not download dist-git file: %v", err) return fmt.Errorf("could not download dist-git file: %v", err)
} }
body, err = ioutil.ReadAll(resp.Body) body, err = io.ReadAll(resp.Body)
if err != nil { if err != nil {
return fmt.Errorf("could not read the whole dist-git file: %v", err) return fmt.Errorf("could not read the whole dist-git file: %v", err)
} }

View File

@ -25,7 +25,6 @@ import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"os" "os"
"os/exec" "os/exec"
@ -1130,7 +1129,7 @@ func convertLocalRepo(pkgName string, localRepo string) (bool, error) {
} }
// Loop through each file/folder and operate accordingly: // Loop through each file/folder and operate accordingly:
files, err := ioutil.ReadDir(localRepo) files, err := os.ReadDir(localRepo)
if err != nil { if err != nil {
return false, err return false, err
} }
@ -1239,7 +1238,7 @@ func getVersionFromSpec(localRepo string, majorVersion int) (string, error) {
// Read the first file from SPECS/ to get our spec file // Read the first file from SPECS/ to get our spec file
// (there should only be one file - we check that it ends in ".spec" just to be sure!) // (there should only be one file - we check that it ends in ".spec" just to be sure!)
lsTmp, err := ioutil.ReadDir(fmt.Sprintf("%s/SPECS/", localRepo)) lsTmp, err := os.ReadDir(fmt.Sprintf("%s/SPECS/", localRepo))
if err != nil { if err != nil {
return "", err return "", err
} }