Skip to content

Commit 36c03f5

Browse files
authored
Merge pull request #724 from skoef/noIOUtil
removed use of deprecated ioutil and go1.15 from CI
2 parents 4c42f69 + 746029a commit 36c03f5

File tree

13 files changed

+38
-47
lines changed

13 files changed

+38
-47
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
go: [ 1.18, 1.17, 1.16, 1.15 ]
8+
go: [ 1.18, 1.17, 1.16 ]
99
name: Tests Go ${{ matrix.go }}
1010
runs-on: ubuntu-18.04
1111

canal/canal.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package canal
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"os"
88
"regexp"
99
"strconv"
@@ -165,7 +165,7 @@ func (c *Canal) prepareDumper() error {
165165
}
166166

167167
if c.cfg.Dump.DiscardErr {
168-
c.dumper.SetErrOut(ioutil.Discard)
168+
c.dumper.SetErrOut(io.Discard)
169169
} else {
170170
c.dumper.SetErrOut(os.Stderr)
171171
}

canal/config.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package canal
22

33
import (
44
"crypto/tls"
5-
"io/ioutil"
65
"math/rand"
76
"net"
87
"os"
@@ -99,7 +98,7 @@ type Config struct {
9998
}
10099

101100
func NewConfigWithFile(name string) (*Config, error) {
102-
data, err := ioutil.ReadFile(name)
101+
data, err := os.ReadFile(name)
103102
if err != nil {
104103
return nil, errors.Trace(err)
105104
}

client/auth.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ func (c *Conn) readInitialHandshake() error {
110110
// generate auth response data according to auth plugin
111111
//
112112
// NOTE: the returned boolean value indicates whether to add a \NUL to the end of data.
113-
// it is quite tricky because MySQL server expects different formats of responses in different auth situations.
114-
// here the \NUL needs to be added when sending back the empty password or cleartext password in 'sha256_password'
115-
// authentication.
113+
// it is quite tricky because MySQL server expects different formats of responses in different auth situations.
114+
// here the \NUL needs to be added when sending back the empty password or cleartext password in 'sha256_password'
115+
// authentication.
116116
func (c *Conn) genAuthResponse(authData []byte) ([]byte, bool, error) {
117117
// password hashing
118118
switch c.authPluginName {

client/client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ func (s *clientTestSuite) TestConn_SetCapability(c *C) {
112112
}
113113

114114
// NOTE for MySQL 5.5 and 5.6, server side has to config SSL to pass the TLS test, otherwise, it will throw error that
115-
// MySQL server does not support TLS required by the client. However, for MySQL 5.7 and above, auto generated certificates
116-
// are used by default so that manual config is no longer necessary.
115+
// MySQL server does not support TLS required by the client. However, for MySQL 5.7 and above, auto generated certificates
116+
// are used by default so that manual config is no longer necessary.
117117
func (s *clientTestSuite) TestConn_TLS_Verify(c *C) {
118118
// Verify that the provided tls.Config is used when attempting to connect to mysql.
119119
// An empty tls.Config will result in a connection error.

client/conn.go

+11-13
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,10 @@ func (c *Conn) Execute(command string, args ...interface{}) (*Result, error) {
217217
//
218218
// Example:
219219
//
220-
// queries := "SELECT 1; SELECT NOW();"
221-
// conn.ExecuteMultiple(queries, func(result *mysql.Result, err error) {
222-
// // Use the result as you want
223-
// })
224-
//
220+
// queries := "SELECT 1; SELECT NOW();"
221+
// conn.ExecuteMultiple(queries, func(result *mysql.Result, err error) {
222+
// // Use the result as you want
223+
// })
225224
func (c *Conn) ExecuteMultiple(query string, perResultCallback ExecPerResultCallback) (*Result, error) {
226225
if err := c.writeCommandStr(COM_QUERY, query); err != nil {
227226
return nil, errors.Trace(err)
@@ -271,20 +270,19 @@ func (c *Conn) ExecuteMultiple(query string, perResultCallback ExecPerResultCall
271270
}
272271

273272
// ExecuteSelectStreaming will call perRowCallback for every row in resultset
274-
// WITHOUT saving any row data to Result.{Values/RawPkg/RowDatas} fields.
273+
// WITHOUT saving any row data to Result.{Values/RawPkg/RowDatas} fields.
275274
// When given, perResultCallback will be called once per result
276275
//
277276
// ExecuteSelectStreaming should be used only for SELECT queries with a large response resultset for memory preserving.
278277
//
279278
// Example:
280279
//
281-
// var result mysql.Result
282-
// conn.ExecuteSelectStreaming(`SELECT ... LIMIT 100500`, &result, func(row []mysql.FieldValue) error {
283-
// // Use the row as you want.
284-
// // You must not save FieldValue.AsString() value after this callback is done. Copy it if you need.
285-
// return nil
286-
// }, nil)
287-
//
280+
// var result mysql.Result
281+
// conn.ExecuteSelectStreaming(`SELECT ... LIMIT 100500`, &result, func(row []mysql.FieldValue) error {
282+
// // Use the row as you want.
283+
// // You must not save FieldValue.AsString() value after this callback is done. Copy it if you need.
284+
// return nil
285+
// }, nil)
288286
func (c *Conn) ExecuteSelectStreaming(command string, result *Result, perRowCallback SelectPerRowCallback, perResultCallback SelectPerResultCallback) error {
289287
if err := c.writeCommandStr(COM_QUERY, command); err != nil {
290288
return errors.Trace(err)

client/pool.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ var (
7575
)
7676

7777
// NewPool initializes new connection pool and uses params: addr, user, password, dbName and options.
78-
// minAlive specifies the minimum number of open connections that the pool will try to maintain.
79-
// maxAlive specifies the maximum number of open connections
80-
// (for internal reasons, may be greater by 1 inside newConnectionProducer).
81-
// maxIdle specifies the maximum number of idle connections (see DefaultIdleTimeout).
78+
// minAlive specifies the minimum number of open connections that the pool will try to maintain.
79+
// maxAlive specifies the maximum number of open connections (for internal reasons,
80+
// may be greater by 1 inside newConnectionProducer).
81+
// maxIdle specifies the maximum number of idle connections (see DefaultIdleTimeout).
8282
func NewPool(
8383
logFunc LogFunc,
8484
minAlive int,

driver/driver.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ func init() {
304304
// Example of supplying a custom CA, no client cert, no key, validating the
305305
// certificate, and supplying a serverName for the validation:
306306
//
307-
// driver.SetCustomTLSConfig(CaPem, make([]byte, 0), make([]byte, 0), false, "my.domain.name")
308-
//
307+
// driver.SetCustomTLSConfig(CaPem, make([]byte, 0), make([]byte, 0), false, "my.domain.name")
309308
func SetCustomTLSConfig(dsn string, caPem []byte, certPem []byte, keyPem []byte, insecureSkipVerify bool, serverName string) error {
310309
// Extract addr from dsn
311310
parsed, err := url.Parse(dsn)

dump/schema_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dump
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"os"
88

99
"github.com/go-mysql-org/go-mysql/client"
@@ -83,19 +83,19 @@ func (s *schemaTestSuite) TestDump(c *C) {
8383
// Using mysql 5.7 can't work, error:
8484
// mysqldump: Error 1412: Table definition has changed,
8585
// please retry transaction when dumping table `test_replication` at row: 0
86-
// err := s.d.Dump(ioutil.Discard)
86+
// err := s.d.Dump(io.Discard)
8787
// c.Assert(err, IsNil)
8888

8989
s.d.AddDatabases("test1", "test2")
9090

9191
s.d.AddIgnoreTables("test1", "t2")
9292

93-
err := s.d.Dump(ioutil.Discard)
93+
err := s.d.Dump(io.Discard)
9494
c.Assert(err, IsNil)
9595

9696
s.d.AddTables("test1", "t1")
9797

98-
err = s.d.Dump(ioutil.Discard)
98+
err = s.d.Dump(io.Discard)
9999
c.Assert(err, IsNil)
100100
}
101101

failover/failover.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ import (
66
)
77

88
// Failover will do below things after the master down
9-
// 1. Elect a slave which has the most up-to-date data with old master
10-
// 2. Promote the slave to new master
11-
// 3. Change other slaves to the new master
9+
// 1. Elect a slave which has the most up-to-date data with old master
10+
// 2. Promote the slave to new master
11+
// 3. Change other slaves to the new master
1212
//
1313
// Limitation:
14-
// 1, All slaves must have the same master before, Failover will check using master server id or uuid
15-
// 2, If the failover error, the whole topology may be wrong, we must handle this error manually
16-
// 3, Slaves must have same replication mode, all use GTID or not
17-
//
14+
// 1, All slaves must have the same master before, Failover will check using master server id or uuid
15+
// 2, If the failover error, the whole topology may be wrong, we must handle this error manually
16+
// 3, Slaves must have same replication mode, all use GTID or not
1817
func Failover(flavor string, slaves []*Server) ([]*Server, error) {
1918
var h Handler
2019
var err error

packet/conn.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ func (b *BufPool) Return(buf *bytes.Buffer) {
4040
b.pool.Put(buf)
4141
}
4242

43-
/*
44-
Conn is the base class to handle MySQL protocol.
45-
*/
43+
// Conn is the base class to handle MySQL protocol.
4644
type Conn struct {
4745
net.Conn
4846

server/caching_sha2_cache_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ var delay = 50
2121

2222
// test caching for 'caching_sha2_password'
2323
// NOTE the idea here is to plugin a throttled credential provider so that the first connection (cache miss) will take longer time
24-
// than the second connection (cache hit). Remember to set the password for MySQL user otherwise it won't cache empty password.
24+
// than the second connection (cache hit). Remember to set the password for MySQL user otherwise it won't cache empty password.
2525
func TestCachingSha2Cache(t *testing.T) {
2626
log.SetLevel(log.LevelDebug)
2727

server/conn.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import (
1111
"github.com/go-mysql-org/go-mysql/packet"
1212
)
1313

14-
/*
15-
Conn acts like a MySQL server connection, you can use MySQL client to communicate with it.
16-
*/
14+
// Conn acts like a MySQL server connection, you can use MySQL client to communicate with it.
1715
type Conn struct {
1816
*packet.Conn
1917

0 commit comments

Comments
 (0)