History

refactor: move from io/ioutil to io and os package (#17109)

The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Eng Zer Jun committed 5 years ago

Commit f2e7d541 parent aa631d8103 files · +261 −314Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 103 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+2−3
@@ -13,7 +13,6 @@ import ( · 12 unmodified lines
1313 "html"
1414 "html/template"
1515 "io"
16− "io/ioutil"
1716 "net/url"
1817 "os"
1918 "os/exec"
@@ -721,7 +720,7 @@ parsingLoop: · 701 unmodified lines
721720 // TODO: Handle skipping first n files
722721 if len(diff.Files) >= maxFiles {
723722 diff.IsIncomplete = true
724− _, err := io.Copy(ioutil.Discard, reader)
723+ _, err := io.Copy(io.Discard, reader)
725724 if err != nil {
726725 // By the definition of io.Copy this never returns io.EOF
727726 return diff, fmt.Errorf("Copy: %v", err)
@@ -1280,7 +1279,7 @@ func GetDiffRangeWithWhitespaceBehavior(gitRepo *git.Repository, beforeCommitID, · 552 unmodified lines
12801279 indexFilename, deleteTemporaryFile, err := gitRepo.ReadTreeToTemporaryIndex(afterCommitID)
12811280 if err == nil {
12821281 defer deleteTemporaryFile()
1283− workdir, err := ioutil.TempDir("", "empty-work-dir")
1282+ workdir, err := os.MkdirTemp("", "empty-work-dir")
12841283 if err != nil {
12851284 log.Error("Unable to create temporary directory: %v", err)
12861285 return nil, err