Repository: mailru/go-clickhouse
Pull request #189 (2024-11-23 02:07:19)

update golang to 1.20
updating to support latest 4 golang versions


Patch:
diff --git a/conn.go b/conn.go
index 4115757..d3d6b4b 100644
--- a/conn.go
+++ b/conn.go
@@ -8,7 +8,6 @@ import (
 	"errors"
 	"fmt"
 	"io"
-	"io/ioutil"
 	"log"
 	"net"
 	"net/http"
@@ -220,7 +219,7 @@ func (c *conn) killQuery(req *http.Request) error {
 	}
 	if body != nil {
 		// Drain body to enable connection reuse
-		_, _ = io.Copy(ioutil.Discard, body)
+		_, _ = io.Copy(io.Discard, body)
 		body.Close()
 	}
 	return nil
@@ -259,7 +258,7 @@ func (c *conn) exec(ctx context.Context, query string, args []driver.Value) (dri
 	body, err := c.doRequest(ctx, req)
 	if body != nil {
 		// Drain body to enable connection reuse
-		_, _ = io.Copy(ioutil.Discard, body)
+		_, _ = io.Copy(io.Discard, body)
 		body.Close()
 	}
 	return emptyResult, err
diff --git a/conn_go18.go b/conn_go18.go
index 2138fe4..db7b625 100644
--- a/conn_go18.go
+++ b/conn_go18.go
@@ -7,7 +7,7 @@ import (
 	"context"
 	"database/sql/driver"
 	"fmt"
-	"io/ioutil"
+	"io"
 	"strings"
 )
 
@@ -37,7 +37,7 @@ func (c *conn) Ping(ctx context.Context) error {
 	defer respBody.Close()
 
 	// drain the response body to check if we got expected `1`
-	resp, err := ioutil.ReadAll(respBody)
+	resp, err := io.ReadAll(respBody)
 	if err != nil {
 		return fmt.Errorf("ping: failed to read the response: %w", err)
 	}
diff --git a/go.mod b/go.mod
index 9e1c282..4921e67 100644
--- a/go.mod
+++ b/go.mod
@@ -1,11 +1,21 @@
 module github.com/mailru/go-clickhouse/v2
 
+go 1.20
+
 require (
-	github.com/google/uuid v1.2.0
-	github.com/stretchr/testify v1.7.1
-	go.opentelemetry.io/otel v1.7.0
-	go.opentelemetry.io/otel/sdk v1.7.0
-	go.opentelemetry.io/otel/trace v1.7.0
+	github.com/google/uuid v1.6.0
+	github.com/stretchr/testify v1.9.0
+	go.opentelemetry.io/otel v1.24.0
+	go.opentelemetry.io/otel/sdk v1.24.0
+	go.opentelemetry.io/otel/trace v1.24.0
 )
 
-go 1.16
+require (
+	github.com/davecgh/go-spew v1.1.1 // indirect
+	github.com/go-logr/logr v1.4.2 // indirect
+	github.com/go-logr/stdr v1.2.2 // indirect
+	github.com/pmezard/go-difflib v1.0.0 // indirect
+	go.opentelemetry.io/otel/metric v1.24.0 // indirect
+	golang.org/x/sys v0.19.0 // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+)
diff --git a/go.sum b/go.sum
index a957be4..e0554f1 100644
--- a/go.sum
+++ b/go.sum
@@ -1,29 +1,28 @@
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
-github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
-github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
-github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
+github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
+github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
 github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
-github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
-github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
-github.com/google/uuid v1.2.0 h1:qJYtXnJRWmpe7m/3XlyhrsLrEURqHRM2kxzoxXqyUDs=
-github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
+github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
-github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-go.opentelemetry.io/otel v1.7.0 h1:Z2lA3Tdch0iDcrhJXDIlC94XE+bxok1F9B+4Lz/lGsM=
-go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk=
-go.opentelemetry.io/otel/sdk v1.7.0 h1:4OmStpcKVOfvDOgCt7UriAPtKolwIhxpnSNI/yK+1B0=
-go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU=
-go.opentelemetry.io/otel/trace v1.7.0 h1:O37Iogk1lEkMRXewVtZ1BBTVn5JEp8GrJvP92bJqC6o=
-go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU=
-golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7 h1:iGu644GcxtEcrInvDsQRCwJjtCIOlT2V7IRt6ah2Whw=
-golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo=
+go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo=
+go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI=
+go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco=
+go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw=
+go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg=
+go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI=
+go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU=
+golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
+golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
 gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
-gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 07ffd1b..b063db6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -12,9 +12,11 @@ jobs:
   lint:
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v2
-      - name: golangci-lint
-        uses: golangci/golangci-lint-action@v2
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Run linter
+        uses: golangci/golangci-lint-action@v6
         with:
           version: latest
 
@@ -25,14 +27,19 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        go: ["1.15", "1.16", "1.17", "1.18"]
+        go: ["1.20", "1.21", "1.22", "1.23"]
 
     steps:
-      - uses: actions/setup-go@v1
+      - name: Checkout
+        uses: actions/checkout@v4
+
+      - name: Set up Go
+        uses: actions/setup-go@v5
         with:
           go-version: ${{ matrix.go }}
-      - uses: actions/checkout@v2
-      - run: go test -v -coverprofile=profile.cov ./...
+
+      - name: Run tests
+        run: go test -v -coverprofile=profile.cov ./...
 
       - name: Send coverage
         uses: shogo82148/actions-goveralls@v1
diff --git a/conn_test.go b/conn_test.go
index 611b40f..1afb095 100644
--- a/conn_test.go
+++ b/conn_test.go
@@ -5,7 +5,7 @@ import (
 	"context"
 	"database/sql"
 	"database/sql/driver"
-	"io/ioutil"
+	"io"
 	"net/http"
 	"strings"
 	"testing"
@@ -17,6 +17,7 @@ import (
 	"go.opentelemetry.io/otel/propagation"
 	"go.opentelemetry.io/otel/sdk/trace"
 	oteltrace "go.opentelemetry.io/otel/trace"
+	"go.opentelemetry.io/otel/trace/noop"
 )
 
 var (
@@ -229,7 +230,7 @@ func (s *connSuite) TestBuildRequestReadonlyWithAuth() {
 		s.Equal(http.MethodPost, req.Method)
 		s.Equal(cn.url.String(), req.URL.String())
 		s.Nil(req.URL.User)
-		b, err := ioutil.ReadAll(req.Body)
+		b, err := io.ReadAll(req.Body)
 		s.Require().NoError(err)
 		s.Equal("SELECT 1", string(b))
 	}
@@ -400,7 +401,7 @@ func (s *connSuite) TestBuildRequestWithTraceContext() {
 		},
 		{
 			name:                       "trace context with noop trace provider",
-			traceProvider:              oteltrace.NewNoopTracerProvider(),
+			traceProvider:              noop.NewTracerProvider(),
 			propagator:                 propagation.TraceContext{},
 			expectedTraceHeaderPresent: false,
 			expectedValidSpan:          false,
@@ -414,7 +415,7 @@ func (s *connSuite) TestBuildRequestWithTraceContext() {
 		},
 		{
 			name:                       "trace context with noop provider and propagator",
-			traceProvider:              oteltrace.NewNoopTracerProvider(),
+			traceProvider:              noop.NewTracerProvider(),
 			propagator:                 propagation.NewCompositeTextMapPropagator(),
 			expectedTraceHeaderPresent: false,
 			expectedValidSpan:          false,
@@ -452,7 +453,7 @@ func (s *connSuite) TestBuildRequestParamsInterpolation() {
 	cn := newConn(NewConfig())
 	req, err := cn.buildRequest(context.Background(), query, make([]driver.Value, 0))
 	if s.NoError(err) {
-		body, e := ioutil.ReadAll(req.Body)
+		body, e := io.ReadAll(req.Body)
 		if s.NoError(e) {
 			s.Equal(query, string(body))
 		}
@@ -469,7 +470,7 @@ func (s *connSuite) TestRequestBodyGzipCompression() {
 		gz, err := gzip.NewReader(req.Body)
 		if s.NoError(err) {
 			defer gz.Close()
-			body, e := ioutil.ReadAll(gz)
+			body, e := io.ReadAll(gz)
 			if s.NoError(e) {
 				s.Equal(query, string(body))
 			}
diff --git a/rows_test.go b/rows_test.go
index d514308..37ae36e 100644
--- a/rows_test.go
+++ b/rows_test.go
@@ -4,7 +4,6 @@ import (
 	"bytes"
 	"database/sql/driver"
 	"io"
-	"io/ioutil"
 	"reflect"
 	"testing"
 	"time"
@@ -42,7 +41,7 @@ func TestTextRows(t *testing.T) {
 		return
 	}
 	assert.Equal(t, []driver.Value{int32(2), "world"}, dest)
-	data, err := ioutil.ReadAll(rows.respBody)
+	data, err := io.ReadAll(rows.respBody)
 	if !assert.NoError(t, err) {
 		return
 	}