Replace deprecated io/ioutil with io and os

pull/1684/head
Oleksandr Redko 2024-12-10 14:21:03 +02:00
parent 89cbdd9e7b
commit 014ae9a7a4
2 changed files with 4 additions and 5 deletions

View File

@ -16,7 +16,6 @@ import (
"go/token" "go/token"
"go/types" "go/types"
"io" "io"
"io/ioutil"
"log" "log"
"os" "os"
"path" "path"
@ -101,7 +100,7 @@ func parseTemplates() (*template.Template, *template.Template, error) {
return nil, nil, err return nil, nil, err
} }
if *tmplFile != "" { if *tmplFile != "" {
f, err := ioutil.ReadFile(*tmplFile) f, err := os.ReadFile(*tmplFile)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -183,7 +182,7 @@ func parsePackageSource(pkg string) (*types.Scope, *doc.Package, error) {
files := make(map[string]*ast.File) files := make(map[string]*ast.File)
fileList := make([]*ast.File, len(pd.GoFiles)) fileList := make([]*ast.File, len(pd.GoFiles))
for i, fname := range pd.GoFiles { for i, fname := range pd.GoFiles {
src, err := ioutil.ReadFile(path.Join(pd.Dir, fname)) src, err := os.ReadFile(path.Join(pd.Dir, fname))
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"errors" "errors"
"flag" "flag"
"io/ioutil" "io"
"math/rand" "math/rand"
"os" "os"
"os/exec" "os/exec"
@ -440,7 +440,7 @@ func (sc *StdoutCapture) StopCapture() (string, error) {
} }
os.Stdout.Close() os.Stdout.Close()
os.Stdout = sc.oldStdout os.Stdout = sc.oldStdout
bytes, err := ioutil.ReadAll(sc.readPipe) bytes, err := io.ReadAll(sc.readPipe)
if err != nil { if err != nil {
return "", err return "", err
} }