Move from deprecated ioutil to os and io packages
This commit is contained in:
parent
46c1600ada
commit
8d739c411b
4 changed files with 15 additions and 15 deletions
|
@ -4,8 +4,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"go/types"
|
"go/types"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -83,7 +83,7 @@ func run(dest string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return ioutil.WriteFile(filepath.Join(dest, "marshaler.go"), []byte(fmt.Sprintf(marsh, destPkg)), 0o666)
|
return os.WriteFile(filepath.Join(dest, "marshaler.go"), []byte(fmt.Sprintf(marsh, destPkg)), 0o666)
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanType(typ types.Type, base string) string {
|
func cleanType(typ types.Type, base string) string {
|
||||||
|
|
|
@ -224,8 +224,8 @@ So we modify the "gRPC server example" to use our own self-signed certificate:
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Read cert and key file
|
// Read cert and key file
|
||||||
backendCert, _ := ioutil.ReadFile("./backend.cert")
|
backendCert, _ := os.ReadFile("./backend.cert")
|
||||||
backendKey, _ := ioutil.ReadFile("./backend.key")
|
backendKey, _ := os.ReadFile("./backend.key")
|
||||||
|
|
||||||
// Generate Certificate struct
|
// Generate Certificate struct
|
||||||
cert, err := tls.X509KeyPair(backendCert, backendKey)
|
cert, err := tls.X509KeyPair(backendCert, backendKey)
|
||||||
|
@ -253,7 +253,7 @@ Next we will modify gRPC Client to use our Traefik self-signed certificate:
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Read cert file
|
// Read cert file
|
||||||
frontendCert, _ := ioutil.ReadFile("./frontend.cert")
|
frontendCert, _ := os.ReadFile("./frontend.cert")
|
||||||
|
|
||||||
// Create CertPool
|
// Create CertPool
|
||||||
roots := x509.NewCertPool()
|
roots := x509.NewCertPool()
|
||||||
|
|
|
@ -3,7 +3,7 @@ package integration
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
@ -331,7 +331,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
||||||
resp, err := client.Do(rootReq)
|
resp, err := client.Do(rootReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
@ -347,7 +347,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
||||||
resp, err := client.Do(fooReq)
|
resp, err := client.Do(fooReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
@ -363,7 +363,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
||||||
resp, err := client.Do(barReq)
|
resp, err := client.Do(barReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
@ -413,7 +413,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
||||||
resp, err := client.Do(rootReq)
|
resp, err := client.Do(rootReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
@ -426,7 +426,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
||||||
resp, err := client.Do(fooReq)
|
resp, err := client.Do(fooReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
@ -439,7 +439,7 @@ func (s *HealthCheckSuite) TestPropagate(c *check.C) {
|
||||||
resp, err := client.Do(barReq)
|
resp, err := client.Do(barReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
@ -533,7 +533,7 @@ func (s *HealthCheckSuite) TestPropagateReload(c *check.C) {
|
||||||
resp, err := client.Do(rootReq)
|
resp, err := client.Do(rootReq)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
body, err := ioutil.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
c.Assert(err, checker.IsNil)
|
c.Assert(err, checker.IsNil)
|
||||||
|
|
||||||
c.Assert(string(body), checker.Contains, want)
|
c.Assert(string(body), checker.Contains, want)
|
||||||
|
|
|
@ -2,7 +2,7 @@ package tcpipwhitelist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ func TestIPWhiteLister_ServeHTTP(t *testing.T) {
|
||||||
whiteLister.ServeTCP(&contextWriteCloser{client, addr{test.remoteAddr}})
|
whiteLister.ServeTCP(&contextWriteCloser{client, addr{test.remoteAddr}})
|
||||||
}()
|
}()
|
||||||
|
|
||||||
read, err := ioutil.ReadAll(server)
|
read, err := io.ReadAll(server)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, test.expected, string(read))
|
assert.Equal(t, test.expected, string(read))
|
||||||
|
|
Loading…
Reference in a new issue