Skip to content

Commit

Permalink
replace ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
yulog committed Jul 6, 2024
1 parent af96178 commit be57f59
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions gocredits.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -124,7 +123,7 @@ func takeCredits(dir string, skipMissing bool) ([]*license, error) {
lpath string
)
for _, lpath = range []string{"LICENSE", "../LICENSE"} {
bs, err = ioutil.ReadFile(filepath.Join(goroot, lpath))
bs, err = os.ReadFile(filepath.Join(goroot, lpath))
if err == nil {
break
}
Expand All @@ -138,7 +137,7 @@ func takeCredits(dir string, skipMissing bool) ([]*license, error) {
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to fetch LICENSE of Go")
}
bs, err = ioutil.ReadAll(resp.Body)
bs, err = io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -224,7 +223,7 @@ func takeCredits(dir string, skipMissing bool) ([]*license, error) {
}

func findLicense(dir string) (string, string, error) {
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
return "", "", err
}
Expand All @@ -246,7 +245,7 @@ func findLicense(dir string) (string, string, error) {
if fileName == "" {
return "", "", os.ErrNotExist
}
bs, err := ioutil.ReadFile(filepath.Join(dir, fileName))
bs, err := os.ReadFile(filepath.Join(dir, fileName))
if err != nil {
return "", "", err
}
Expand Down
3 changes: 1 addition & 2 deletions gocredits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gocredits

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -31,7 +30,7 @@ func TestLicenseDirs_set(t *testing.T) {
}

func TestTakeCredits(t *testing.T) {
tmpd, err := ioutil.TempDir("", "gocredits-")
tmpd, err := os.MkdirTemp("", "gocredits-")
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit be57f59

Please sign in to comment.