mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-15 18:57:01 +00:00
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:
parent
5878bd0f57
commit
fef9bd3448
7 changed files with 25 additions and 30 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue