Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace io/ioutil to os/io in golang 1.19 #357

Merged
merged 1 commit into from
Jun 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions test/e2e/util/common_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"context"
"fmt"
"io"
"io/ioutil"
"math/rand"
"net/http"
"os"
Expand Down Expand Up @@ -58,7 +57,7 @@ func WriteTextFile(filePath, content string) error {
if len(content) > 0 && content[len(content)-1] != '\n' {
content += "\n"
}
return ioutil.WriteFile(filePath, []byte(content), 0600)
return os.WriteFile(filePath, []byte(content), 0600)
}

// GitRootDir returns the absolute path to the root directory of the git repo
Expand Down Expand Up @@ -91,18 +90,19 @@ func Poll(interval time.Duration, numTrials int, do func() (bool, error)) error

// CreateTempfile creates a tempfile string.
func CreateTempfile(tmpDir, prefix, suffix string) (string, error) {
f, err := ioutil.TempFile(tmpDir, prefix)
f, err := os.CreateTemp(tmpDir, prefix)
if err != nil {
return "", err
}
var tmpName string
if tmpName, err = filepath.Abs(f.Name()); err != nil {
name := f.Name()
if tmpName, err = filepath.Abs(name); err != nil {
return "", err
}
if err = f.Close(); err != nil {
return "", err
}
if err = os.Remove(tmpName); err != nil {
if err = os.RemoveAll(tmpName); err != nil {
log.Errorf("CreateTempfile unable to remove %s", tmpName)
return "", err
}
Expand All @@ -116,7 +116,7 @@ func WriteTempfile(tmpDir, prefix, suffix, contents string) (string, error) {
return "", err
}

if err := ioutil.WriteFile(fname, []byte(contents), 0644); err != nil {
if err := os.WriteFile(fname, []byte(contents), 0644); err != nil {
return "", err
}
return fname, nil
Expand Down Expand Up @@ -192,7 +192,7 @@ func Record(command, record string) error {
if err != nil {
return err
}
err = ioutil.WriteFile(record, []byte(resp), 0600)
err = os.WriteFile(record, []byte(resp), 0600)
return err
}

Expand Down