Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 138f216

Browse filesBrowse files
authored
Merge pull request #1251 from Workiva/updateDeps
Updating deprecated method calls
2 parents c7cfb39 + 3e3c85e commit 138f216
Copy full SHA for 138f216

File tree

Expand file treeCollapse file tree

8 files changed

+24
-29
lines changed
Filter options
Expand file treeCollapse file tree

8 files changed

+24
-29
lines changed

‎compiler/natives/src/net/http/http.go

Copy file name to clipboardExpand all lines: compiler/natives/src/net/http/http.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"bufio"
88
"bytes"
99
"errors"
10-
"io/ioutil"
10+
"io"
1111
"net/textproto"
1212
"strconv"
1313

@@ -68,7 +68,7 @@ func (t *XHRTransport) RoundTrip(req *Request) (*Response, error) {
6868
StatusCode: xhr.Get("status").Int(),
6969
Header: Header(header),
7070
ContentLength: contentLength,
71-
Body: ioutil.NopCloser(bytes.NewReader(body)),
71+
Body: io.NopCloser(bytes.NewReader(body)),
7272
Request: req,
7373
}
7474
})
@@ -91,7 +91,7 @@ func (t *XHRTransport) RoundTrip(req *Request) (*Response, error) {
9191
if req.Body == nil {
9292
xhr.Call("send")
9393
} else {
94-
body, err := ioutil.ReadAll(req.Body)
94+
body, err := io.ReadAll(req.Body)
9595
if err != nil {
9696
req.Body.Close() // RoundTrip must always close the body, including on errors.
9797
return nil, err

‎go.mod

Copy file name to clipboardExpand all lines: go.mod
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@ require (
1313
github.com/spf13/cobra v1.2.1
1414
github.com/spf13/pflag v1.0.5
1515
github.com/visualfc/goembed v0.3.3
16-
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
1716
golang.org/x/sync v0.3.0
1817
golang.org/x/sys v0.10.0
18+
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
1919
golang.org/x/tools v0.11.0
2020
)
2121

2222
require (
2323
github.com/inconshreveable/mousetrap v1.0.0 // indirect
24-
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
2524
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
2625
)

‎go.sum

Copy file name to clipboardExpand all lines: go.sum
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
260260
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
261261
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
262262
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
263-
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
264-
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
265263
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
266264
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
267265
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=

‎tests/gorepo/run.go

Copy file name to clipboardExpand all lines: tests/gorepo/run.go
+12-13Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"fmt"
2525
"hash/fnv"
2626
"io"
27-
"io/ioutil"
2827
"log"
2928
"os"
3029
"os/exec"
@@ -457,8 +456,8 @@ func (t *test) goDirName() string {
457456
return filepath.Join(t.dir, strings.Replace(t.gofile, ".go", ".dir", -1))
458457
}
459458

460-
func goDirFiles(longdir string) (filter []os.FileInfo, err error) {
461-
files, dirErr := ioutil.ReadDir(longdir)
459+
func goDirFiles(longdir string) (filter []os.DirEntry, err error) {
460+
files, dirErr := os.ReadDir(longdir)
462461
if dirErr != nil {
463462
return nil, dirErr
464463
}
@@ -481,7 +480,7 @@ func goDirPackages(longdir string) ([][]string, error) {
481480
m := make(map[string]int)
482481
for _, file := range files {
483482
name := file.Name()
484-
data, err := ioutil.ReadFile(filepath.Join(longdir, name))
483+
data, err := os.ReadFile(filepath.Join(longdir, name))
485484
if err != nil {
486485
return nil, err
487486
}
@@ -593,7 +592,7 @@ func (t *test) run() {
593592
return
594593
}
595594

596-
srcBytes, err := ioutil.ReadFile(t.goFileName())
595+
srcBytes, err := os.ReadFile(t.goFileName())
597596
if err != nil {
598597
t.err = err
599598
return
@@ -682,7 +681,7 @@ func (t *test) run() {
682681
t.makeTempDir()
683682
defer os.RemoveAll(t.tempDir)
684683

685-
err = ioutil.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0o644)
684+
err = os.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0o644)
686685
check(err)
687686

688687
// A few tests (of things like the environment) require these to be set.
@@ -854,7 +853,7 @@ func (t *test) run() {
854853
return
855854
}
856855
tfile := filepath.Join(t.tempDir, "tmp__.go")
857-
if err := ioutil.WriteFile(tfile, out, 0o666); err != nil {
856+
if err := os.WriteFile(tfile, out, 0o666); err != nil {
858857
t.err = fmt.Errorf("write tempfile:%s", err)
859858
return
860859
}
@@ -875,7 +874,7 @@ func (t *test) run() {
875874
return
876875
}
877876
tfile := filepath.Join(t.tempDir, "tmp__.go")
878-
err = ioutil.WriteFile(tfile, out, 0o666)
877+
err = os.WriteFile(tfile, out, 0o666)
879878
if err != nil {
880879
t.err = fmt.Errorf("write tempfile:%s", err)
881880
return
@@ -923,15 +922,15 @@ func (t *test) String() string {
923922

924923
func (t *test) makeTempDir() {
925924
var err error
926-
t.tempDir, err = ioutil.TempDir("", "")
925+
t.tempDir, err = os.MkdirTemp("", "")
927926
check(err)
928927
}
929928

930929
func (t *test) expectedOutput() string {
931930
filename := filepath.Join(t.dir, t.gofile)
932931
filename = filename[:len(filename)-len(".go")]
933932
filename += ".out"
934-
b, _ := ioutil.ReadFile(filename)
933+
b, _ := os.ReadFile(filename)
935934
return string(b)
936935
}
937936

@@ -1023,7 +1022,7 @@ func (t *test) errorCheck(outStr string, fullshort ...string) (err error) {
10231022

10241023
func (t *test) updateErrors(out string, file string) {
10251024
// Read in source file.
1026-
src, err := ioutil.ReadFile(file)
1025+
src, err := os.ReadFile(file)
10271026
if err != nil {
10281027
fmt.Fprintln(os.Stderr, err)
10291028
return
@@ -1078,7 +1077,7 @@ func (t *test) updateErrors(out string, file string) {
10781077
}
10791078
}
10801079
// Write new file.
1081-
err = ioutil.WriteFile(file, []byte(strings.Join(lines, "\n")), 0o640)
1080+
err = os.WriteFile(file, []byte(strings.Join(lines, "\n")), 0o640)
10821081
if err != nil {
10831082
fmt.Fprintln(os.Stderr, err)
10841083
return
@@ -1135,7 +1134,7 @@ var (
11351134
func (t *test) wantedErrors(file, short string) (errs []wantedError) {
11361135
cache := make(map[string]*regexp.Regexp)
11371136

1138-
src, _ := ioutil.ReadFile(file)
1137+
src, _ := os.ReadFile(file)
11391138
for i, line := range strings.Split(string(src), "\n") {
11401139
lineNum := i + 1
11411140
if strings.Contains(line, "////") {

‎tests/js_test.go

Copy file name to clipboardExpand all lines: tests/js_test.go
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ func TestInternalizeStruct(t *testing.T) {
326326
t.Errorf("Mismatch (-want +got):\n%s", diff)
327327
}
328328
}
329+
329330
func TestInternalizeStructUnexportedFields(t *testing.T) {
330331
type Person struct {
331332
Name string

‎tests/lowlevel_test.go

Copy file name to clipboardExpand all lines: tests/lowlevel_test.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package tests_test
22

33
import (
4-
"io/ioutil"
4+
"os"
55
"os/exec"
66
"path/filepath"
77
"runtime"
@@ -26,7 +26,7 @@ func TestTimeInternalizationExternalization(t *testing.T) {
2626
t.Fatalf("%v:\n%s", err, got)
2727
}
2828

29-
wantb, err := ioutil.ReadFile(filepath.Join("testdata", "time_inexternalization.out"))
29+
wantb, err := os.ReadFile(filepath.Join("testdata", "time_inexternalization.out"))
3030
want := string(wantb)
3131
if err != nil {
3232
t.Fatalf("error reading .out file: %v", err)

‎tests/syscall_test.go

Copy file name to clipboardExpand all lines: tests/syscall_test.go
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package tests
55

66
import (
7-
"io/ioutil"
87
"os"
98
"syscall"
109
"testing"
@@ -20,7 +19,7 @@ func TestGetpid(t *testing.T) {
2019
}
2120

2221
func TestOpen(t *testing.T) {
23-
f, err := ioutil.TempFile("", "")
22+
f, err := os.CreateTemp("", "")
2423
if err != nil {
2524
t.Fatalf("Failed to create a temp file: %s", err)
2625
}

‎tool.go

Copy file name to clipboardExpand all lines: tool.go
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"go/token"
1111
"go/types"
1212
"io"
13-
"io/ioutil"
1413
"net"
1514
"net/http"
1615
"os"
@@ -35,8 +34,8 @@ import (
3534
log "github.com/sirupsen/logrus"
3635
"github.com/spf13/cobra"
3736
"github.com/spf13/pflag"
38-
"golang.org/x/crypto/ssh/terminal"
3937
"golang.org/x/sync/errgroup"
38+
"golang.org/x/term"
4039
)
4140

4241
var currentDirectory string
@@ -79,7 +78,7 @@ func main() {
7978

8079
compilerFlags := pflag.NewFlagSet("", 0)
8180
compilerFlags.BoolVarP(&options.Minify, "minify", "m", false, "minify generated code")
82-
compilerFlags.BoolVar(&options.Color, "color", terminal.IsTerminal(int(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb", "colored output")
81+
compilerFlags.BoolVar(&options.Color, "color", term.IsTerminal(int(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb", "colored output")
8382
compilerFlags.StringVar(&tags, "tags", "", "a list of build tags to consider satisfied during the build")
8483
compilerFlags.BoolVar(&options.MapToLocalDisk, "localmap", false, "use local paths for sourcemap")
8584
compilerFlags.BoolVarP(&options.NoCache, "no_cache", "a", false, "rebuild all packages from scratch")
@@ -280,9 +279,9 @@ func main() {
280279
return fmt.Errorf("gopherjs run: no go files listed")
281280
}
282281

283-
tempfile, err := ioutil.TempFile(currentDirectory, filepath.Base(args[0])+".")
282+
tempfile, err := os.CreateTemp(currentDirectory, filepath.Base(args[0])+".")
284283
if err != nil && strings.HasPrefix(currentDirectory, runtime.GOROOT()) {
285-
tempfile, err = ioutil.TempFile("", filepath.Base(args[0])+".")
284+
tempfile, err = os.CreateTemp("", filepath.Base(args[0])+".")
286285
}
287286
if err != nil {
288287
return err

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.