Skip to content
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

Replace deprecated io/ioutil functions with equivalents #1211

Merged
merged 1 commit into from
Mar 1, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 4 additions & 5 deletions conn_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"database/sql/driver"
"fmt"
"io"
"io/ioutil"
"log"
"mime/multipart"
"net"
Expand Down Expand Up @@ -86,7 +85,7 @@ func (rw HTTPReaderWriter) read(res *http.Response) ([]byte, error) {
if err := reader.Reset(res.Body); err != nil {
return nil, err
}
body, err := ioutil.ReadAll(reader)
body, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
Expand All @@ -97,7 +96,7 @@ func (rw HTTPReaderWriter) read(res *http.Response) ([]byte, error) {
if err := rw.reader.(flate.Resetter).Reset(res.Body, nil); err != nil {
return nil, err
}
body, err := ioutil.ReadAll(reader)
body, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
Expand All @@ -107,14 +106,14 @@ func (rw HTTPReaderWriter) read(res *http.Response) ([]byte, error) {
if err := reader.Reset(res.Body); err != nil {
return nil, err
}
body, err := ioutil.ReadAll(reader)
body, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
return body, nil
}
}
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions conn_http_async_insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package clickhouse
import (
"context"
"io"
"io/ioutil"
)

func (h *httpConnect) asyncInsert(ctx context.Context, query string, wait bool, args ...any) error {
Expand All @@ -43,7 +42,7 @@ func (h *httpConnect) asyncInsert(ctx context.Context, query string, wait bool,
if res != nil {
defer res.Body.Close()
// we don't care about result, so just discard it to reuse connection
_, _ = io.Copy(ioutil.Discard, res.Body)
_, _ = io.Copy(io.Discard, res.Body)
}

return err
Expand Down
10 changes: 5 additions & 5 deletions conn_http_batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import (
"context"
"errors"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2/lib/column"
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
"io"
"io/ioutil"
"regexp"
"strings"

"github.com/ClickHouse/clickhouse-go/v2/lib/column"
"github.com/ClickHouse/clickhouse-go/v2/lib/driver"
"github.com/ClickHouse/clickhouse-go/v2/lib/proto"
)

// \x60 represents a backtick
Expand Down Expand Up @@ -224,7 +224,7 @@ func (b *httpBatch) Send() (err error) {
if res != nil {
defer res.Body.Close()
// we don't care about result, so just discard it to reuse connection
_, _ = io.Copy(ioutil.Discard, res.Body)
_, _ = io.Copy(io.Discard, res.Body)
}

return err
Expand Down
3 changes: 1 addition & 2 deletions conn_http_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package clickhouse
import (
"context"
"io"
"io/ioutil"
)

func (h *httpConnect) exec(ctx context.Context, query string, args ...any) error {
Expand All @@ -34,7 +33,7 @@ func (h *httpConnect) exec(ctx context.Context, query string, args ...any) error
if res != nil {
defer res.Body.Close()
// we don't care about result, so just discard it to reuse connection
_, _ = io.Copy(ioutil.Discard, res.Body)
_, _ = io.Copy(io.Discard, res.Body)
}

return err
Expand Down
6 changes: 3 additions & 3 deletions examples/clickhouse_api/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2"
"io/ioutil"
"os"
"path"

"github.com/ClickHouse/clickhouse-go/v2"
)

func SSLVersion() error {
Expand All @@ -37,7 +37,7 @@ func SSLVersion() error {
return err
}
t := &tls.Config{}
caCert, err := ioutil.ReadFile(path.Join(cwd, "../../tests/resources/CAroot.crt"))
caCert, err := os.ReadFile(path.Join(cwd, "../../tests/resources/CAroot.crt"))
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions examples/std/ssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"crypto/x509"
"database/sql"
"fmt"
"github.com/ClickHouse/clickhouse-go/v2"
"io/ioutil"
"os"
"path"

"github.com/ClickHouse/clickhouse-go/v2"
)

func ConnectSSL() error {
Expand All @@ -38,7 +38,7 @@ func ConnectSSL() error {
return err
}
t := &tls.Config{}
caCert, err := ioutil.ReadFile(path.Join(cwd, "../../tests/resources/CAroot.crt"))
caCert, err := os.ReadFile(path.Join(cwd, "../../tests/resources/CAroot.crt"))
if err != nil {
return err
}
Expand Down