Re: [go-nuts] Go vet context leak error

2017-02-06 Thread Sameer Ajmani
Perhaps just read the deadline in the lock, then do the rest outside the lock: func (s *SimplePeerConn) Read(b []byte) (n int, err error) { s.deadlineLock.RLock() deadline := s.readDeadline s.deadlineLock.RUnlock() ctx := context.Background() if !deadline.IsZero() { dctx, cancel :=

[go-nuts] Go vet context leak error

2017-02-06 Thread chad . retz
I have the following function: func (s *SimplePeerConn) Read(b []byte) (n int, err error) { ctx := context.Background() var maybeCancelFn context.CancelFunc func() { s.deadlineLock.RLock() defer s.deadlineLock.RUnlock() if !s.readDeadline.IsZero() { ctx, maybeCancelFn = con