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 (
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
)
@ -65,7 +65,7 @@ func (f *File) Read(path string) ([]byte, error) {
return nil, err
}
body, err := ioutil.ReadAll(r)
body, err := io.ReadAll(r)
if err != nil {
return nil, err
}

View File

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

View File

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

View File

@ -23,7 +23,7 @@ package directives
import (
"errors"
"fmt"
"io/ioutil"
"io"
"os"
"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))
}
replacingBytes, err = ioutil.ReadAll(fPatch)
replacingBytes, err = io.ReadAll(fPatch)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_READ_FROM:%s", addType.File))
}

View File

@ -27,7 +27,7 @@ import (
"crypto/sha256"
"errors"
"fmt"
"io/ioutil"
"io"
"os"
"path/filepath"
"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))
}
bts, err := ioutil.ReadAll(f)
bts, err := io.ReadAll(f)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_READ_FILE:%s", path))
}

View File

@ -23,7 +23,7 @@ package directives
import (
"errors"
"fmt"
"io/ioutil"
"io"
"os"
"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))
}
replacingBytes, err := ioutil.ReadAll(fPatch)
replacingBytes, err := io.ReadAll(fPatch)
if err != nil {
return errors.New(fmt.Sprintf("COULD_NOT_READ_REPLACING:%s", replacing.WithFile))
}

View File

@ -23,7 +23,7 @@ package directives
import (
"errors"
"fmt"
"io/ioutil"
"io"
"math"
"os"
"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")
}
specBts, err := ioutil.ReadAll(specFile)
specBts, err := io.ReadAll(specFile)
if err != nil {
return errors.New("COULD_NOT_READ_ALL_BYTES")
}

View File

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

View File

@ -4,7 +4,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"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)
}
fileBytes, err := ioutil.ReadAll(metadataFile)
fileBytes, err := io.ReadAll(metadataFile)
if err != nil {
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)
}
body, err = ioutil.ReadAll(resp.Body)
body, err = io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("could not read the whole dist-git file: %v", err)
}

View File

@ -25,7 +25,6 @@ import (
"encoding/hex"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
@ -1130,7 +1129,7 @@ func convertLocalRepo(pkgName string, localRepo string) (bool, error) {
}
// Loop through each file/folder and operate accordingly:
files, err := ioutil.ReadDir(localRepo)
files, err := os.ReadDir(localRepo)
if err != nil {
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
// (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 {
return "", err
}