瀏覽代碼

Update golangci-lint to 1.44.2

tags/v2.1.5^2
9seconds 4 年之前
父節點
當前提交
5282ca26f3

+ 1
- 1
.github/workflows/ci.yaml 查看文件

@@ -83,7 +83,7 @@ jobs:
83 83
       - name: Run linter
84 84
         uses: golangci/golangci-lint-action@v2
85 85
         with:
86
-          version: v1.43.0
86
+          version: v1.44.2
87 87
 
88 88
   docker:
89 89
     name: Docker

+ 1
- 1
.golangci.toml 查看文件

@@ -9,4 +9,4 @@ format = "colored-line-number"
9 9
 
10 10
 [linters]
11 11
 enable-all = true
12
-disable = ["ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct"]
12
+disable = ["ireturn", "varnamelen", "gochecknoglobals", "gas", "goerr113", "exhaustivestruct", "containedctx"]

+ 1
- 1
Makefile 查看文件

@@ -2,7 +2,7 @@ ROOT_DIR     := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
2 2
 IMAGE_NAME   := mtg
3 3
 APP_NAME     := $(IMAGE_NAME)
4 4
 
5
-GOLANGCI_LINT_VERSION := v1.43.0
5
+GOLANGCI_LINT_VERSION := v1.44.2
6 6
 
7 7
 VERSION_GO         := $(shell go version)
8 8
 VERSION_DATE       := $(shell date -Ru)

+ 3
- 3
internal/testlib/mtglib_network_mock.go 查看文件

@@ -15,16 +15,16 @@ type MtglibNetworkMock struct {
15 15
 func (m *MtglibNetworkMock) Dial(network, address string) (essentials.Conn, error) {
16 16
 	args := m.Called(network, address)
17 17
 
18
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
18
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
19 19
 }
20 20
 
21 21
 func (m *MtglibNetworkMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
22 22
 	args := m.Called(ctx, network, address)
23 23
 
24
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
24
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
25 25
 }
26 26
 
27 27
 func (m *MtglibNetworkMock) MakeHTTPClient(dialFunc func(ctx context.Context,
28 28
 	network, address string) (essentials.Conn, error)) *http.Client {
29
-	return m.Called(dialFunc).Get(0).(*http.Client)
29
+	return m.Called(dialFunc).Get(0).(*http.Client) // nolint: forcetypeassert
30 30
 }

+ 2
- 2
internal/testlib/net_conn_mock.go 查看文件

@@ -36,11 +36,11 @@ func (n *EssentialsConnMock) CloseWrite() error {
36 36
 }
37 37
 
38 38
 func (n *EssentialsConnMock) LocalAddr() net.Addr {
39
-	return n.Called().Get(0).(net.Addr)
39
+	return n.Called().Get(0).(net.Addr) // nolint: forcetypeassert
40 40
 }
41 41
 
42 42
 func (n *EssentialsConnMock) RemoteAddr() net.Addr {
43
-	return n.Called().Get(0).(net.Addr)
43
+	return n.Called().Get(0).(net.Addr) // nolint: forcetypeassert
44 44
 }
45 45
 
46 46
 func (n *EssentialsConnMock) SetDeadline(t time.Time) error {

+ 1
- 1
mtglib/internal/faketls/pools.go 查看文件

@@ -12,7 +12,7 @@ var bytesBufferPool = sync.Pool{
12 12
 }
13 13
 
14 14
 func acquireBytesBuffer() *bytes.Buffer {
15
-	return bytesBufferPool.Get().(*bytes.Buffer)
15
+	return bytesBufferPool.Get().(*bytes.Buffer) // nolint: forcetypeassert
16 16
 }
17 17
 
18 18
 func releaseBytesBuffer(b *bytes.Buffer) {

+ 1
- 1
mtglib/internal/faketls/record/pools.go 查看文件

@@ -11,7 +11,7 @@ var recordPool = sync.Pool{
11 11
 }
12 12
 
13 13
 func AcquireRecord() *Record {
14
-	return recordPool.Get().(*Record)
14
+	return recordPool.Get().(*Record) // nolint: forcetypeassert
15 15
 }
16 16
 
17 17
 func ReleaseRecord(r *Record) {

+ 2
- 2
mtglib/internal/obfuscated2/pools.go 查看文件

@@ -21,7 +21,7 @@ var (
21 21
 )
22 22
 
23 23
 func acquireSha256Hasher() hash.Hash {
24
-	return sha256HasherPool.Get().(hash.Hash)
24
+	return sha256HasherPool.Get().(hash.Hash) // nolint: forcetypeassert
25 25
 }
26 26
 
27 27
 func releaseSha256Hasher(h hash.Hash) {
@@ -30,7 +30,7 @@ func releaseSha256Hasher(h hash.Hash) {
30 30
 }
31 31
 
32 32
 func acquireBytesBuffer() *bytes.Buffer {
33
-	return bytesBufferPool.Get().(*bytes.Buffer)
33
+	return bytesBufferPool.Get().(*bytes.Buffer) // nolint: forcetypeassert
34 34
 }
35 35
 
36 36
 func releaseBytesBuffer(buf *bytes.Buffer) {

+ 2
- 2
mtglib/internal/obfuscated2/server_handshake_test.go 查看文件

@@ -69,7 +69,7 @@ func (suite *ServerHandshakeTestSuite) TestSendToTelegram() {
69 69
 		Once().
70 70
 		Run(func(args mock.Arguments) {
71 71
 			message := make([]byte, len(messageToTelegram))
72
-			suite.decryptor.XORKeyStream(message, args.Get(0).([]byte))
72
+			suite.decryptor.XORKeyStream(message, args.Get(0).([]byte)) // nolint: forcetypeassert
73 73
 			suite.Equal(messageToTelegram, message)
74 74
 		})
75 75
 
@@ -89,7 +89,7 @@ func (suite *ServerHandshakeTestSuite) TestRecieveFromTelegram() {
89 89
 		Run(func(args mock.Arguments) {
90 90
 			message := make([]byte, len(messageFromTelegram))
91 91
 			suite.encryptor.XORKeyStream(message, messageFromTelegram)
92
-			copy(args.Get(0).([]byte), message)
92
+			copy(args.Get(0).([]byte), message) // nolint: forcetypeassert
93 93
 		})
94 94
 
95 95
 	n, err := suite.proxyConn.Read(buffer)

+ 1
- 1
mtglib/internal/relay/pools.go 查看文件

@@ -11,7 +11,7 @@ var copyBufferPool = sync.Pool{
11 11
 }
12 12
 
13 13
 func acquireCopyBuffer() *[]byte {
14
-	return copyBufferPool.Get().(*[]byte)
14
+	return copyBufferPool.Get().(*[]byte) // nolint: forcetypeassert
15 15
 }
16 16
 
17 17
 func releaseCopyBuffer(buf *[]byte) {

+ 6
- 3
mtglib/proxy.go 查看文件

@@ -106,7 +106,7 @@ func (p *Proxy) Serve(listener net.Listener) error { // nolint: cyclop
106 106
 			}
107 107
 		}
108 108
 
109
-		ipAddr := conn.RemoteAddr().(*net.TCPAddr).IP
109
+		ipAddr := conn.RemoteAddr().(*net.TCPAddr).IP // nolint: forcetypeassert
110 110
 		logger := p.logger.BindStr("ip", ipAddr.String())
111 111
 
112 112
 		if p.whitelist != nil && !p.whitelist.Contains(ipAddr) {
@@ -255,7 +255,10 @@ func (p *Proxy) doTelegramCall(ctx *streamContext) error {
255 255
 	}
256 256
 
257 257
 	p.eventStream.Send(ctx,
258
-		NewEventConnectedToDC(ctx.streamID, conn.RemoteAddr().(*net.TCPAddr).IP, ctx.dc))
258
+		NewEventConnectedToDC(ctx.streamID,
259
+			conn.RemoteAddr().(*net.TCPAddr).IP, // nolint: forcetypeassert
260
+			ctx.dc),
261
+	)
259 262
 
260 263
 	return nil
261 264
 }
@@ -316,7 +319,7 @@ func NewProxy(opts ProxyOpts) (*Proxy, error) {
316 319
 
317 320
 	pool, err := ants.NewPoolWithFunc(opts.getConcurrency(),
318 321
 		func(arg interface{}) {
319
-			proxy.ServeConn(arg.(essentials.Conn))
322
+			proxy.ServeConn(arg.(essentials.Conn)) // nolint: forcetypeassert
320 323
 		},
321 324
 		ants.WithLogger(opts.getLogger("ants")),
322 325
 		ants.WithNonblocking(true))

+ 1
- 1
mtglib/stream_context.go 查看文件

@@ -49,7 +49,7 @@ func (s *streamContext) Close() {
49 49
 }
50 50
 
51 51
 func (s *streamContext) ClientIP() net.IP {
52
-	return s.clientConn.RemoteAddr().(*net.TCPAddr).IP
52
+	return s.clientConn.RemoteAddr().(*net.TCPAddr).IP // nolint: forcetypeassert
53 53
 }
54 54
 
55 55
 func newStreamContext(ctx context.Context, logger Logger, clientConn essentials.Conn) *streamContext {

+ 1
- 1
network/default.go 查看文件

@@ -36,7 +36,7 @@ func (d *defaultDialer) DialContext(ctx context.Context, network, address string
36 36
 		return nil, fmt.Errorf("cannot set socket options: %w", err)
37 37
 	}
38 38
 
39
-	return conn.(essentials.Conn), nil
39
+	return conn.(essentials.Conn), nil // nolint: forcetypeassert
40 40
 }
41 41
 
42 42
 // NewDefaultDialer build a new dialer which dials bypassing proxies

+ 2
- 2
network/init_internal_test.go 查看文件

@@ -14,11 +14,11 @@ type DialerMock struct {
14 14
 func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
15 15
 	args := d.Called(network, address)
16 16
 
17
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
17
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
18 18
 }
19 19
 
20 20
 func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
21 21
 	args := d.Called(ctx, network, address)
22 22
 
23
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
23
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
24 24
 }

+ 2
- 2
network/init_test.go 查看文件

@@ -22,13 +22,13 @@ type DialerMock struct {
22 22
 func (d *DialerMock) Dial(network, address string) (essentials.Conn, error) {
23 23
 	args := d.Called(network, address)
24 24
 
25
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
25
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
26 26
 }
27 27
 
28 28
 func (d *DialerMock) DialContext(ctx context.Context, network, address string) (essentials.Conn, error) {
29 29
 	args := d.Called(ctx, network, address)
30 30
 
31
-	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck
31
+	return args.Get(0).(essentials.Conn), args.Error(1) // nolint: wrapcheck, forcetypeassert
32 32
 }
33 33
 
34 34
 type HTTPServerTestSuite struct {

+ 2
- 2
network/sockopts.go 查看文件

@@ -10,13 +10,13 @@ import (
10 10
 //
11 11
 // bufferSize setting is deprecated and ignored.
12 12
 func SetClientSocketOptions(conn net.Conn, bufferSize int) error {
13
-	return setCommonSocketOptions(conn.(*net.TCPConn))
13
+	return setCommonSocketOptions(conn.(*net.TCPConn)) // nolint: forcetypeassert
14 14
 }
15 15
 
16 16
 // SetServerSocketOptions tunes a TCP socket that represents a connection to
17 17
 // remote server like Telegram or fronting domain (but not end user).
18 18
 func SetServerSocketOptions(conn net.Conn, bufferSize int) error {
19
-	return setCommonSocketOptions(conn.(*net.TCPConn))
19
+	return setCommonSocketOptions(conn.(*net.TCPConn)) // nolint: forcetypeassert
20 20
 }
21 21
 
22 22
 func setCommonSocketOptions(conn *net.TCPConn) error {

+ 1
- 1
stats/pools.go 查看文件

@@ -11,7 +11,7 @@ var streamInfoPool = sync.Pool{
11 11
 }
12 12
 
13 13
 func acquireStreamInfo() *streamInfo {
14
-	return streamInfoPool.Get().(*streamInfo)
14
+	return streamInfoPool.Get().(*streamInfo) // nolint: forcetypeassert
15 15
 }
16 16
 
17 17
 func releaseStreamInfo(info *streamInfo) {

Loading…
取消
儲存