mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
refactor: change deprecated "io/ioutil" package to recommended "io" package
This commit is contained in:
parent
35984c0876
commit
acce1f1fd9
14 changed files with 25 additions and 39 deletions
|
@ -3,7 +3,6 @@ package snowflake_client
|
|||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
@ -115,7 +114,7 @@ func (r *ampCacheRendezvous) Exchange(encPollReq []byte) ([]byte, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
encPollResp, err := ioutil.ReadAll(dec)
|
||||
encPollResp, err := io.ReadAll(dec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
@ -71,7 +70,7 @@ func (r *httpRendezvous) Exchange(encPollReq []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
func limitedRead(r io.Reader, limit int64) ([]byte, error) {
|
||||
p, err := ioutil.ReadAll(&io.LimitedReader{R: r, N: limit + 1})
|
||||
p, err := io.ReadAll(&io.LimitedReader{R: r, N: limit + 1})
|
||||
if err != nil {
|
||||
return p, err
|
||||
} else if int64(len(p)) == limit+1 {
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"testing"
|
||||
|
@ -32,7 +31,7 @@ func (t *mockTransport) RoundTrip(req *http.Request) (*http.Response, error) {
|
|||
return &http.Response{
|
||||
Status: fmt.Sprintf("%d %s", t.statusCode, http.StatusText(t.statusCode)),
|
||||
StatusCode: t.statusCode,
|
||||
Body: ioutil.NopCloser(bytes.NewReader(t.body)),
|
||||
Body: io.NopCloser(bytes.NewReader(t.body)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
|
@ -198,7 +197,7 @@ func main() {
|
|||
// buffer is full.
|
||||
// https://bugs.torproject.org/26360
|
||||
// https://bugs.torproject.org/25600#comment:14
|
||||
var logOutput = ioutil.Discard
|
||||
var logOutput = io.Discard
|
||||
if *logFilename != "" {
|
||||
if *logToStateDir || *oldLogToStateDir {
|
||||
stateDir, err := pt.MakeStateDir()
|
||||
|
@ -298,8 +297,8 @@ func main() {
|
|||
// This environment variable means we should treat EOF on stdin
|
||||
// just like SIGTERM: https://bugs.torproject.org/15435.
|
||||
go func() {
|
||||
if _, err := io.Copy(ioutil.Discard, os.Stdin); err != nil {
|
||||
log.Printf("calling io.Copy(ioutil.Discard, os.Stdin) returned error: %v", err)
|
||||
if _, err := io.Copy(io.Discard, os.Stdin); err != nil {
|
||||
log.Printf("calling io.Copy(io.Discard, os.Stdin) returned error: %v", err)
|
||||
}
|
||||
log.Printf("synthesizing SIGTERM because of stdin close")
|
||||
sigChan <- syscall.SIGTERM
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue