mirror of
https://github.com/go-micro/go-micro.git
synced 2025-11-23 21:44:41 +02:00
replace ioutil with io and os (#2327)
set the go version to 1.16 in pr.yml and tests.yml, so as to be consistent with the version in go.mod.
This commit is contained in:
4
.github/workflows/pr.yml
vendored
4
.github/workflows/pr.yml
vendored
@@ -8,10 +8,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.15
|
- name: Set up Go 1.16
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: 1.16
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
|||||||
4
.github/workflows/tests.yml
vendored
4
.github/workflows/tests.yml
vendored
@@ -8,10 +8,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Set up Go 1.15
|
- name: Set up Go 1.16
|
||||||
uses: actions/setup-go@v1
|
uses: actions/setup-go@v1
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: 1.16
|
||||||
id: go
|
id: go
|
||||||
|
|
||||||
- name: Check out code into the Go module directory
|
- name: Check out code into the Go module directory
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go-micro.dev/v4/api/server"
|
"go-micro.dev/v4/api/server"
|
||||||
"go-micro.dev/v4/api/server/cors"
|
"go-micro.dev/v4/api/server/cors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -28,7 +28,7 @@ func TestHTTPServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ func TestCORSHTTPServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -300,7 +299,7 @@ func (h *httpBroker) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
req.ParseForm()
|
req.ParseForm()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(req.Body)
|
b, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errr := merr.InternalServerError("go.micro.broker", "Error reading request body: %v", err)
|
errr := merr.InternalServerError("go.micro.broker", "Error reading request body: %v", err)
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
@@ -558,7 +557,7 @@ func (h *httpBroker) Publish(topic string, msg *Message, opts ...PublishOption)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// discard response body
|
// discard response body
|
||||||
io.Copy(ioutil.Discard, r.Body)
|
io.Copy(io.Discard, r.Body)
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go-micro.dev/v4/cmd/protoc-gen-micro/generator"
|
"go-micro.dev/v4/cmd/protoc-gen-micro/generator"
|
||||||
@@ -63,7 +63,7 @@ func main() {
|
|||||||
// report failure.
|
// report failure.
|
||||||
g := generator.New()
|
g := generator.New()
|
||||||
|
|
||||||
data, err := ioutil.ReadAll(os.Stdin)
|
data, err := io.ReadAll(os.Stdin)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
g.Error(err, "reading input")
|
g.Error(err, "reading input")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package bytes
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"go-micro.dev/v4/codec"
|
"go-micro.dev/v4/codec"
|
||||||
)
|
)
|
||||||
@@ -24,7 +23,7 @@ func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
|
|||||||
|
|
||||||
func (c *Codec) ReadBody(b interface{}) error {
|
func (c *Codec) ReadBody(b interface{}) error {
|
||||||
// read bytes
|
// read bytes
|
||||||
buf, err := ioutil.ReadAll(c.Conn)
|
buf, err := io.ReadAll(c.Conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package proto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"go-micro.dev/v4/codec"
|
"go-micro.dev/v4/codec"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@@ -21,7 +20,7 @@ func (c *Codec) ReadBody(b interface{}) error {
|
|||||||
if b == nil {
|
if b == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
buf, err := ioutil.ReadAll(c.Conn)
|
buf, err := io.ReadAll(c.Conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ package text
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"go-micro.dev/v4/codec"
|
"go-micro.dev/v4/codec"
|
||||||
)
|
)
|
||||||
@@ -24,7 +23,7 @@ func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
|
|||||||
|
|
||||||
func (c *Codec) ReadBody(b interface{}) error {
|
func (c *Codec) ReadBody(b interface{}) error {
|
||||||
// read bytes
|
// read bytes
|
||||||
buf, err := ioutil.ReadAll(c.Conn)
|
buf, err := io.ReadAll(c.Conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package cli
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -119,7 +119,7 @@ func NewSource(opts ...source.Option) source.Source {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parse flags
|
// parse flags
|
||||||
set.SetOutput(ioutil.Discard)
|
set.SetOutput(io.Discard)
|
||||||
set.Parse(os.Args[1:])
|
set.Parse(os.Args[1:])
|
||||||
|
|
||||||
// normalise flags
|
// normalise flags
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
package file
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"go-micro.dev/v4/config/source"
|
"go-micro.dev/v4/config/source"
|
||||||
@@ -23,7 +23,7 @@ func (f *file) Read() (*source.ChangeSet, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer fh.Close()
|
defer fh.Close()
|
||||||
b, err := ioutil.ReadAll(fh)
|
b, err := io.ReadAll(fh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
"go-micro.dev/v4/config"
|
"go-micro.dev/v4/config"
|
||||||
"github.com/asim/go-micro/plugins/config/encoder/toml/v4"
|
"github.com/asim/go-micro/plugins/config/encoder/toml/v4"
|
||||||
@@ -51,7 +51,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write the file
|
// write the file
|
||||||
if err := ioutil.WriteFile("./example.conf", v, 0644); err != nil {
|
if err := os.WriteFile("./example.conf", v, 0644); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
@@ -24,7 +24,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package token
|
package token
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestGenerate(t *testing.T) {
|
func TestGenerate(t *testing.T) {
|
||||||
privKey, err := ioutil.ReadFile("test/sample_key")
|
privKey, err := os.ReadFile("test/sample_key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to read private key: %v", err)
|
t.Fatalf("Unable to read private key: %v", err)
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,11 @@ func TestGenerate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInspect(t *testing.T) {
|
func TestInspect(t *testing.T) {
|
||||||
pubKey, err := ioutil.ReadFile("test/sample_key.pub")
|
pubKey, err := os.ReadFile("test/sample_key.pub")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to read public key: %v", err)
|
t.Fatalf("Unable to read public key: %v", err)
|
||||||
}
|
}
|
||||||
privKey, err := ioutil.ReadFile("test/sample_key")
|
privKey, err := os.ReadFile("test/sample_key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Unable to read private key: %v", err)
|
t.Fatalf("Unable to read private key: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -304,7 +303,7 @@ func (h *httpBroker) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
req.ParseForm()
|
req.ParseForm()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(req.Body)
|
b, err := io.ReadAll(req.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errr := merr.InternalServerError("go.micro.broker", "Error reading request body: %v", err)
|
errr := merr.InternalServerError("go.micro.broker", "Error reading request body: %v", err)
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
@@ -562,7 +561,7 @@ func (h *httpBroker) Publish(topic string, msg *broker.Message, opts ...broker.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
// discard response body
|
// discard response body
|
||||||
io.Copy(ioutil.Discard, r.Body)
|
io.Copy(io.Discard, r.Body)
|
||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"go-micro.dev/v4/broker"
|
"go-micro.dev/v4/broker"
|
||||||
@@ -109,7 +108,7 @@ func (s *sidecar) Publish(topic string, msg *broker.Message, opts ...broker.Publ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// discard response
|
// discard response
|
||||||
io.Copy(ioutil.Discard, rsp.Body)
|
io.Copy(io.Discard, rsp.Body)
|
||||||
rsp.Body.Close()
|
rsp.Body.Close()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -137,7 +137,7 @@ func (h *httpClient) call(ctx context.Context, node *registry.Node, req client.R
|
|||||||
defer hrsp.Body.Close()
|
defer hrsp.Body.Close()
|
||||||
|
|
||||||
// parse response
|
// parse response
|
||||||
b, err = ioutil.ReadAll(hrsp.Body)
|
b, err = io.ReadAll(hrsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.InternalServerError("go.micro.client", err.Error())
|
return errors.InternalServerError("go.micro.client", err.Error())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -41,7 +41,7 @@ func TestHTTPClient(t *testing.T) {
|
|||||||
http.Error(w, "codec not found", 500)
|
http.Error(w, "codec not found", 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
@@ -146,7 +146,7 @@ func TestHTTPClientStream(t *testing.T) {
|
|||||||
http.Error(w, "codec not found", 500)
|
http.Error(w, "codec not found", 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
@@ -191,7 +191,7 @@ func TestHTTPClientStream(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err = ioutil.ReadAll(r.Body)
|
b, err = io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -102,7 +102,7 @@ func (h *httpStream) Recv(msg interface{}) error {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package pkger
|
package pkger
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
|
|
||||||
"github.com/markbates/pkger"
|
"github.com/markbates/pkger"
|
||||||
"go-micro.dev/v4/config/source"
|
"go-micro.dev/v4/config/source"
|
||||||
@@ -22,7 +22,7 @@ func (f *file) Read() (*source.ChangeSet, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer fh.Close()
|
defer fh.Close()
|
||||||
b, err := ioutil.ReadAll(fh)
|
b, err := io.ReadAll(fh)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
package url
|
package url
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ func (u *urlSource) Read() (*source.ChangeSet, error) {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -174,7 +173,7 @@ func (p *Router) ServeRequest(ctx context.Context, req server.Request, rsp serve
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read body
|
// read body
|
||||||
b, err := ioutil.ReadAll(hrsp.Body)
|
b, err := io.ReadAll(hrsp.Body)
|
||||||
hrsp.Body.Close()
|
hrsp.Body.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.InternalServerError(req.Service(), err.Error())
|
return errors.InternalServerError(req.Service(), err.Error())
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"compress/zlib"
|
"compress/zlib"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io"
|
||||||
|
|
||||||
"go-micro.dev/v4/registry"
|
"go-micro.dev/v4/registry"
|
||||||
)
|
)
|
||||||
@@ -35,7 +35,7 @@ func decode(d string) []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
rbuf, err := ioutil.ReadAll(zr)
|
rbuf, err := io.ReadAll(zr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -179,7 +179,7 @@ func configure(g *gossipRegistry, opts ...registry.Option) error {
|
|||||||
c := memberlist.DefaultLocalConfig()
|
c := memberlist.DefaultLocalConfig()
|
||||||
|
|
||||||
// sane good default options
|
// sane good default options
|
||||||
c.LogOutput = ioutil.Discard // log to /dev/null
|
c.LogOutput = io.Discard // log to /dev/null
|
||||||
c.PushPullInterval = 0 // disable expensive tcp push/pull
|
c.PushPullInterval = 0 // disable expensive tcp push/pull
|
||||||
c.ProtocolVersion = 4 // suport latest stable features
|
c.ProtocolVersion = 4 // suport latest stable features
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
log "go-micro.dev/v4/logger"
|
log "go-micro.dev/v4/logger"
|
||||||
@@ -84,7 +84,7 @@ func newResponse(res *http.Response, err error) *Response {
|
|||||||
|
|
||||||
log.Errorf("K8s: request failed with code %v", r.res.StatusCode)
|
log.Errorf("K8s: request failed with code %v", r.res.StatusCode)
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(r.res.Body)
|
b, err := io.ReadAll(r.res.Body)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
log.Error("K8s: request failed with body:")
|
log.Error("K8s: request failed with body:")
|
||||||
log.Error(string(b))
|
log.Error(string(b))
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package client
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -54,7 +53,7 @@ func detectNamespace() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the file, and cast to a string
|
// Read the file, and cast to a string
|
||||||
if ns, e := ioutil.ReadFile(nsPath); e != nil {
|
if ns, e := os.ReadFile(nsPath); e != nil {
|
||||||
return string(ns), e
|
return string(ns), e
|
||||||
} else {
|
} else {
|
||||||
return string(ns), nil
|
return string(ns), nil
|
||||||
@@ -97,7 +96,7 @@ func NewClientInCluster() Kubernetes {
|
|||||||
log.Fatal(errors.New("no k8s service account found"))
|
log.Fatal(errors.New("no k8s service account found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := ioutil.ReadFile(path.Join(serviceAccountPath, "token"))
|
token, err := os.ReadFile(path.Join(serviceAccountPath, "token"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
// COPIED FROM
|
// COPIED FROM
|
||||||
@@ -31,7 +31,7 @@ func certificatesFromFile(file string) ([]*x509.Certificate, error) {
|
|||||||
if len(file) == 0 {
|
if len(file) == 0 {
|
||||||
return nil, errors.New("error reading certificates from an empty filename")
|
return nil, errors.New("error reading certificates from an empty filename")
|
||||||
}
|
}
|
||||||
pemBlock, err := ioutil.ReadFile(file)
|
pemBlock, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
@@ -75,7 +74,7 @@ func (s *proxy) Register(service *registry.Service, opts ...registry.RegisterOpt
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if rsp.StatusCode != 200 {
|
if rsp.StatusCode != 200 {
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -83,7 +82,7 @@ func (s *proxy) Register(service *registry.Service, opts ...registry.RegisterOpt
|
|||||||
gerr = errors.New(string(b))
|
gerr = errors.New(string(b))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
io.Copy(ioutil.Discard, rsp.Body)
|
io.Copy(io.Discard, rsp.Body)
|
||||||
rsp.Body.Close()
|
rsp.Body.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -117,7 +116,7 @@ func (s *proxy) Deregister(service *registry.Service, opts ...registry.Deregiste
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rsp.StatusCode != 200 {
|
if rsp.StatusCode != 200 {
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -126,7 +125,7 @@ func (s *proxy) Deregister(service *registry.Service, opts ...registry.Deregiste
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
io.Copy(ioutil.Discard, rsp.Body)
|
io.Copy(io.Discard, rsp.Body)
|
||||||
rsp.Body.Close()
|
rsp.Body.Close()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -149,7 +148,7 @@ func (s *proxy) GetService(service string, opts ...registry.GetOption) ([]*regis
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rsp.StatusCode != 200 {
|
if rsp.StatusCode != 200 {
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -158,7 +157,7 @@ func (s *proxy) GetService(service string, opts ...registry.GetOption) ([]*regis
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gerr = err
|
gerr = err
|
||||||
continue
|
continue
|
||||||
@@ -189,7 +188,7 @@ func (s *proxy) ListServices(opts ...registry.ListOption) ([]*registry.Service,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rsp.StatusCode != 200 {
|
if rsp.StatusCode != 200 {
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -198,7 +197,7 @@ func (s *proxy) ListServices(opts ...registry.ListOption) ([]*registry.Service,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
gerr = err
|
gerr = err
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ func TestHTTPServer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -114,7 +114,7 @@ func decode(record []string) (*mdnsTxt, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rbuf, err := ioutil.ReadAll(zr)
|
rbuf, err := io.ReadAll(zr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package docker
|
|||||||
import (
|
import (
|
||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
"bytes"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ func (d *Builder) Build(s *build.Source) (*build.Package, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// read docker file
|
// read docker file
|
||||||
by, err := ioutil.ReadAll(f)
|
by, err := io.ReadAll(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ func (d *Builder) Build(s *build.Source) (*build.Package, error) {
|
|||||||
Name: image,
|
Name: image,
|
||||||
Dockerfile: dockerFile,
|
Dockerfile: dockerFile,
|
||||||
InputStream: tr,
|
InputStream: tr,
|
||||||
OutputStream: ioutil.Discard,
|
OutputStream: io.Discard,
|
||||||
RmTmpContainer: true,
|
RmTmpContainer: true,
|
||||||
SuppressOutput: true,
|
SuppressOutput: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -144,7 +143,7 @@ func (h *httpTransportClient) Recv(m *Message) error {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -218,7 +217,7 @@ func (h *httpTransportSocket) Recv(m *Message) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read body
|
// read body
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -292,7 +291,7 @@ func (h *httpTransportSocket) Send(m *Message) error {
|
|||||||
|
|
||||||
rsp := &http.Response{
|
rsp := &http.Response{
|
||||||
Header: hdr,
|
Header: hdr,
|
||||||
Body: ioutil.NopCloser(bytes.NewReader(m.Body)),
|
Body: io.NopCloser(bytes.NewReader(m.Body)),
|
||||||
Status: "200 OK",
|
Status: "200 OK",
|
||||||
StatusCode: 200,
|
StatusCode: 200,
|
||||||
Proto: "HTTP/1.1",
|
Proto: "HTTP/1.1",
|
||||||
@@ -343,7 +342,7 @@ func (h *httpTransportSocket) error(m *Message) error {
|
|||||||
if h.r.ProtoMajor == 1 {
|
if h.r.ProtoMajor == 1 {
|
||||||
rsp := &http.Response{
|
rsp := &http.Response{
|
||||||
Header: make(http.Header),
|
Header: make(http.Header),
|
||||||
Body: ioutil.NopCloser(bytes.NewReader(m.Body)),
|
Body: io.NopCloser(bytes.NewReader(m.Body)),
|
||||||
Status: "500 Internal Server Error",
|
Status: "500 Internal Server Error",
|
||||||
StatusCode: 500,
|
StatusCode: 500,
|
||||||
Proto: "HTTP/1.1",
|
Proto: "HTTP/1.1",
|
||||||
@@ -403,12 +402,12 @@ func (h *httpTransportListener) Accept(fn func(Socket)) error {
|
|||||||
|
|
||||||
// read a regular request
|
// read a regular request
|
||||||
if r.ProtoMajor == 1 {
|
if r.ProtoMajor == 1 {
|
||||||
b, err := ioutil.ReadAll(r.Body)
|
b, err := io.ReadAll(r.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
r.Body = ioutil.NopCloser(bytes.NewReader(b))
|
r.Body = io.NopCloser(bytes.NewReader(b))
|
||||||
// hijack the conn
|
// hijack the conn
|
||||||
hj, ok := w.(http.Hijacker)
|
hj, ok := w.(http.Hijacker)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package http
|
package http
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -48,7 +48,7 @@ func TestRoundTripper(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(w.Body)
|
b, err := io.ReadAll(w.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ func TestRoundTripper(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err = ioutil.ReadAll(rsp.Body)
|
b, err = io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ func newResponse(res *http.Response, err error) *Response {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(r.res.Body)
|
b, err := io.ReadAll(r.res.Body)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
r.err = errors.New(string(b))
|
r.err = errors.New(string(b))
|
||||||
return r
|
return r
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import (
|
|||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@@ -360,7 +359,7 @@ func NewClusterClient() *client {
|
|||||||
logger.Fatal(errors.New("service account not found"))
|
logger.Fatal(errors.New("service account not found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
token, err := ioutil.ReadFile(path.Join(serviceAccountPath, "token"))
|
token, err := os.ReadFile(path.Join(serviceAccountPath, "token"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal(err)
|
logger.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
@@ -45,7 +45,7 @@ func certificatesFromFile(file string) ([]*x509.Certificate, error) {
|
|||||||
if len(file) == 0 {
|
if len(file) == 0 {
|
||||||
return nil, errors.New("error reading certificates from an empty filename")
|
return nil, errors.New("error reading certificates from an empty filename")
|
||||||
}
|
}
|
||||||
pemBlock, err := ioutil.ReadFile(file)
|
pemBlock, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package web
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -80,7 +80,7 @@ func TestService(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ func TestTLS(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer rsp.Body.Close()
|
defer rsp.Body.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadAll(rsp.Body)
|
b, err := io.ReadAll(rsp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user