8000 Updating deprecated method calls by grantnelson-wf · Pull Request #1251 · gopherjs/gopherjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Updating deprecated method calls #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/natives/src/net/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"bufio"
"bytes"
"errors"
"io/ioutil"
"io"
"net/textproto"
"strconv"

Expand Down Expand Up @@ -68,7 +68,7 @@ func (t *XHRTransport) RoundTrip(req *Request) (*Response, error) {
StatusCode: xhr.Get("status").Int(),
Header: Header(header),
ContentLength: contentLength,
Body: ioutil.NopCloser(bytes.NewReader(body)),
Body: io.NopCloser(bytes.NewReader(body)),
Request: req,
}
})
Expand All @@ -91,7 +91,7 @@ func (t *XHRTransport) RoundTrip(req *Request) (*Response, error) {
if req.Body == nil {
xhr.Call("send")
} else {
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
req.Body.Close() // RoundTrip must always close the body, including on errors.
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ require (
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
github.com/visualfc/goembed v0.3.3
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
golang.org/x/sync v0.3.0
golang.org/x/sys v0.10.0
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171
golang.org/x/tools v0.11.0
)

require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
golang.org/x/term v0.0.0-20220411215600-e5f449aeb171 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA=
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down
25 changes: 12 additions & 13 deletions tests/gorepo/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"fmt"
"hash/fnv"
"io"
"io/ioutil"
"log"
"os"
"os/exec"
Expand Down Expand Up @@ -457,8 +456,8 @@ func (t *test) goDirName() string {
return filepath.Join(t.dir, strings.Replace(t.gofile, ".go", ".dir", -1))
}

func goDirFiles(longdir string) (filter []os.FileInfo, err error) {
files, dirErr := ioutil.ReadDir(longdir)
func goDirFiles(longdir string) (filter []os.DirEntry, err error) {
files, dirErr := os.ReadDir(longdir)
if dirErr != nil {
return nil, dirErr
}
Expand All @@ -481,7 +480,7 @@ func goDirPackages(longdir string) ([][]string, error) {
m := make(map[string]int)
for _, file := range files {
name := file.Name()
data, err := ioutil.ReadFile(filepath.Join(longdir, name))
data, err := os.ReadFile(filepath.Join(longdir, name))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -593,7 +592,7 @@ func (t *test) run() {
return
}

srcBytes, err := ioutil.ReadFile(t.goFileName())
srcBytes, err := os.ReadFile(t.goFileName())
if err != nil {
t.err = err
return
Expand Down Expand Up @@ -682,7 +681,7 @@ func (t *test) run() {
t.makeTempDir()
defer os.RemoveAll(t.tempDir)

err = ioutil.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0o644)
err = os.WriteFile(filepath.Join(t.tempDir, t.gofile), srcBytes, 0o644)
check(err)

// A few tests (of things like the environment) require these to be set.
Expand Down Expand Up @@ -854,7 +853,7 @@ func (t *test) run() {
return
}
tfile := filepath.Join(t.tempDir, "tmp__.go")
if err := ioutil.WriteFile(tfile, out, 0o666); err != nil {
if err := os.WriteFile(tfile, out, 0o666); err != nil {
t.err = fmt.Errorf("write tempfile:%s", err)
return
}
Expand All @@ -875,7 +874,7 @@ func (t *test) run() {
return
}
tfile := filepath.Join(t.tempDir, "tmp__.go")
err = ioutil.WriteFile(tfile, out, 0o666)
err = os.WriteFile(tfile, out, 0o666)
if err != nil {
t.err = fmt.Errorf("write tempfile:%s", err)
return
Expand Down Expand Up @@ -923,15 +922,15 @@ func (t *test) String() string {

func (t *test) makeTempDir() {
var err error
t.tempDir, err = ioutil.TempDir("", "")
t.tempDir, err = os.MkdirTemp("", "")
check(err)
}

func (t *test) expectedOutput() string {
filename := filepath.Join(t.dir, t.gofile)
filename = filename[:len(filename)-len(".go")]
filename += ".out"
b, _ := ioutil.ReadFile(filename)
b, _ := os.ReadFile(filename)
return string(b)
}

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

func (t *test) updateErrors(out string, file string) {
// Read in source file.
src, err := ioutil.ReadFile(file)
src, err := os.ReadFile(file)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
Expand Down Expand Up @@ -1078,7 +1077,7 @@ func (t *test) updateErrors(out string, file string) {
}
}
// Write new file.
err = ioutil.WriteFile(file, []byte(strings.Join(lines, "\n")), 0o640)
err = os.WriteFile(file, []byte(strings.Join(lines, "\n")), 0o640)
if err != nil {
fmt.Fprintln(os.Stderr, err)
return
Expand Down Expand Up @@ -1135,7 +1134,7 @@ var (
func (t *test) wantedErrors(file, short string) (errs []wantedError) {
cache := make(map[string]*regexp.Regexp)

src, _ := ioutil.ReadFile(file)
src, _ := os.ReadFile(file)
for i, line := range strings.Split(string(src), "\n") {
lineNum := i + 1
if strings.Contains(line, "////") {
Expand Down
1 change: 1 addition & 0 deletions tests/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ func TestInternalizeStruct(t *testing.T) {
t.Errorf("Mismatch (-want +got):\n%s", diff)
}
}

func TestInternalizeStructUnexportedFields(t *testing.T) {
type Person struct {
Name string
Expand Down
4 changes: 2 additions & 2 deletions tests/lowlevel_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tests_test

import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
Expand All @@ -26,7 +26,7 @@ func TestTimeInternalizationExternalization(t *testing.T) {
t.Fatalf("%v:\n%s", err, got)
}

wantb, err := ioutil.ReadFile(filepath.Join("testdata", "time_inexternalization.out"))
wantb, err := os.ReadFile(filepath.Join("testdata", "time_inexternalization.out"))
want := string(wantb)
if err != nil {
t.Fatalf("error reading .out file: %v", err)
Expand Down
3 changes: 1 addition & 2 deletions tests/syscall_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package tests

import (
"io/ioutil"
"os"
"syscall"
"testing"
Expand All @@ -20,7 +19,7 @@ func TestGetpid(t *testing.T) {
}

func TestOpen(t *testing.T) {
f, err := ioutil.TempFile("", "")
f, err := os.CreateTemp("", "")
if err != nil {
t.Fatalf("Failed to create a temp file: %s", err)
}
Expand Down
9 changes: 4 additions & 5 deletions tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"go/token"
"go/types"
"io"
"io/ioutil"
"net"
"net/http"
"os"
Expand All @@ -35,8 +34,8 @@ import (
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/sync/errgroup"
"golang.org/x/term"
)

var currentDirectory string
Expand Down Expand Up @@ -79,7 +78,7 @@ func main() {

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

tempfile, err := ioutil.TempFile(currentDirectory, filepath.Base(args[0])+".")
tempfile, err := os.CreateTemp(currentDirectory, filepath.Base(args[0])+".")
if err != nil && strings.HasPrefix(currentDirectory, runtime.GOROOT()) {
tempfile, err = ioutil.TempFile("", filepath.Base(args[0])+".")
tempfile, err = os.CreateTemp("", filepath.Base(args[0])+".")
}
if err != nil {
return err
Expand Down
0