Skip to content

Commit 01d21d3

Browse files
committed
gbn+mailbox: fix linter issues
1 parent ada573d commit 01d21d3

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

gbn/gbn_client.go

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ func NewClientConn(ctx context.Context, n uint8, sendFunc sendBytesFunc,
4141

4242
// clientHandshake initiates the client side GBN handshake.
4343
// The handshake sequence from the client side is as follows:
44-
// 1. The client sends SYN to the server along with the N value that the
45-
// client wishes to use for the connection.
46-
// 2. The client then waits for the server to respond with SYN.
47-
// 3a. If the client receives SYN from the server then the client sends back
48-
// SYNACK.
44+
// 1. The client sends SYN to the server along with the N value that the
45+
// client wishes to use for the connection.
46+
// 2. The client then waits for the server to respond with SYN.
47+
// 3a. If the client receives SYN from the server, then the client sends back
48+
// SYNACK.
4949
// 3b. If the client does not receive SYN from the server within a given
50-
// timeout, then the client restarts the handshake from step 1.
50+
// timeout, then the client restarts the handshake from step 1.
5151
func (g *GoBackNConn) clientHandshake() error {
5252
// Spin off the recv function in a goroutine so that we can use
5353
// a select to choose to timeout waiting for data from the receive
@@ -94,7 +94,10 @@ func (g *GoBackNConn) clientHandshake() error {
9494
}
9595
}()
9696

97-
var resp Message
97+
var (
98+
resp Message
99+
respSYN *PacketSYN
100+
)
98101
handshake:
99102
for {
100103
// start Handshake
@@ -142,8 +145,10 @@ handshake:
142145
}
143146

144147
log.Debugf("Client got %T", resp)
145-
switch resp.(type) {
148+
switch r := resp.(type) {
146149
case *PacketSYN:
150+
respSYN = r
151+
147152
break handshake
148153
default:
149154
}
@@ -155,7 +160,8 @@ handshake:
155160
}
156161

157162
log.Debugf("Client got SYN")
158-
if resp.(*PacketSYN).N != g.n {
163+
164+
if respSYN.N != g.n {
159165
return io.EOF
160166
}
161167

gbn/gbn_conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ type GoBackNConn struct {
9797
pongTicker *IntervalAwareForceTicker
9898
pongWait chan struct{}
9999

100-
ctx context.Context
100+
ctx context.Context //nolint:containedctx
101101
cancel func()
102102

103103
// remoteClosed is closed if the remote party initiated the FIN sequence.

mailbox/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Server struct {
2626

2727
sid [64]byte
2828

29-
ctx context.Context
29+
ctx context.Context //nolint:containedctx
3030

3131
quit chan struct{}
3232
cancel func()

0 commit comments

Comments
 (0)