refactor: move from io/ioutil to io and os packages (#1417)
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. [1]: https://golang.org/doc/go1.16#ioutil Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -48,9 +48,7 @@ func CopyDir(source string, dest string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
directory, _ := os.Open(source)
|
||||
|
||||
objects, err := directory.Readdir(-1)
|
||||
objects, err := os.ReadDir(source)
|
||||
|
||||
for _, obj := range objects {
|
||||
sourcefilepointer := source + "/" + obj.Name()
|
||||
|
@@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
@@ -61,7 +60,7 @@ func FindGitRevision(ctx context.Context, file string) (shortSha string, sha str
|
||||
return "", "", err
|
||||
}
|
||||
|
||||
bts, err := ioutil.ReadFile(filepath.Join(gitDir, "HEAD"))
|
||||
bts, err := os.ReadFile(filepath.Join(gitDir, "HEAD"))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
@@ -70,7 +69,7 @@ func FindGitRevision(ctx context.Context, file string) (shortSha string, sha str
|
||||
var refBuf []byte
|
||||
if strings.HasPrefix(ref, "refs/") {
|
||||
// load commitid ref
|
||||
refBuf, err = ioutil.ReadFile(filepath.Join(gitDir, ref))
|
||||
refBuf, err = os.ReadFile(filepath.Join(gitDir, ref))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
@@ -151,7 +150,7 @@ func findGitPrettyRef(ctx context.Context, head, root, sub string) (string, erro
|
||||
return nil
|
||||
}
|
||||
var bts []byte
|
||||
if bts, err = ioutil.ReadFile(path); err != nil {
|
||||
if bts, err = os.ReadFile(path); err != nil {
|
||||
return err
|
||||
}
|
||||
var pointsTo = strings.TrimSpace(string(bts))
|
||||
|
@@ -3,7 +3,6 @@ package git
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -45,7 +44,7 @@ func TestFindGitSlug(t *testing.T) {
|
||||
}
|
||||
|
||||
func testDir(t *testing.T) string {
|
||||
basedir, err := ioutil.TempDir("", "act-test")
|
||||
basedir, err := os.MkdirTemp("", "act-test")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { _ = os.RemoveAll(basedir) })
|
||||
return basedir
|
||||
@@ -53,7 +52,7 @@ func testDir(t *testing.T) string {
|
||||
|
||||
func cleanGitHooks(dir string) error {
|
||||
hooksDir := filepath.Join(dir, ".git", "hooks")
|
||||
files, err := ioutil.ReadDir(hooksDir)
|
||||
files, err := os.ReadDir(hooksDir)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user