@@ -94,7 +94,7 @@ func (c *connection) AddCloseCallback(callback CloseCallback) error {
9494 if callback == nil {
9595 return nil
9696 }
97- var cb = & callbackNode {}
97+ cb : = & callbackNode {}
9898 cb .fn = callback
9999 if pre := c .closeCallbacks .Load (); pre != nil {
100100 cb .pre = pre .(* callbackNode )
@@ -132,7 +132,7 @@ func (c *connection) onPrepare(opts *options) (err error) {
132132
133133// onConnect is responsible for executing onRequest if there is new data coming after onConnect callback finished.
134134func (c * connection ) onConnect () {
135- var onConnect , _ = c .onConnectCallback .Load ().(OnConnect )
135+ onConnect , _ : = c .onConnectCallback .Load ().(OnConnect )
136136 if onConnect == nil {
137137 c .changeState (connStateNone , connStateConnected )
138138 return
@@ -141,17 +141,17 @@ func (c *connection) onConnect() {
141141 // it never happens because onDisconnect will not lock connecting if c.connected == 0
142142 return
143143 }
144- var onRequest , _ = c .onRequestCallback .Load ().(OnRequest )
144+ onRequest , _ : = c .onRequestCallback .Load ().(OnRequest )
145145 c .onProcess (onConnect , onRequest )
146146}
147147
148148// when onDisconnect called, c.IsActive() must return false
149149func (c * connection ) onDisconnect () {
150- var onDisconnect , _ = c .onDisconnectCallback .Load ().(OnDisconnect )
150+ onDisconnect , _ : = c .onDisconnectCallback .Load ().(OnDisconnect )
151151 if onDisconnect == nil {
152152 return
153153 }
154- var onConnect , _ = c .onConnectCallback .Load ().(OnConnect )
154+ onConnect , _ : = c .onConnectCallback .Load ().(OnConnect )
155155 if onConnect == nil {
156156 // no need lock if onConnect is nil
157157 // it's ok to force set state to disconnected since onConnect is nil
@@ -170,12 +170,11 @@ func (c *connection) onDisconnect() {
170170 return
171171 }
172172 // OnConnect is not finished yet, return and let onConnect helps to call onDisconnect
173- return
174173}
175174
176175// onRequest is responsible for executing the closeCallbacks after the connection has been closed.
177176func (c * connection ) onRequest () (needTrigger bool ) {
178- var onRequest , ok = c .onRequestCallback .Load ().(OnRequest )
177+ onRequest , ok : = c .onRequestCallback .Load ().(OnRequest )
179178 if ! ok {
180179 return true
181180 }
@@ -270,8 +269,8 @@ func (c *connection) onProcess(onConnect OnConnect, onRequest OnRequest) (proces
270269 }
271270 // task exits
272271 panicked = false
273- return
274- }
272+ } // end of task closure func
273+
275274 // add new task
276275 runTask (c .ctx , task )
277276 return true
@@ -280,7 +279,7 @@ func (c *connection) onProcess(onConnect OnConnect, onRequest OnRequest) (proces
280279// closeCallback .
281280// It can be confirmed that closeCallback and onRequest will not be executed concurrently.
282281// If onRequest is still running, it will trigger closeCallback on exit.
283- func (c * connection ) closeCallback (needLock bool , needDetach bool ) (err error ) {
282+ func (c * connection ) closeCallback (needLock , needDetach bool ) (err error ) {
284283 if needLock && ! c .lock (processing ) {
285284 return nil
286285 }
@@ -290,7 +289,7 @@ func (c *connection) closeCallback(needLock bool, needDetach bool) (err error) {
290289 logger .Printf ("NETPOLL: closeCallback[%v,%v] detach operator failed: %v" , needLock , needDetach , err )
291290 }
292291 }
293- var latest = c .closeCallbacks .Load ()
292+ latest : = c .closeCallbacks .Load ()
294293 if latest == nil {
295294 return nil
296295 }
0 commit comments