github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/tcp/util.go (about) 1 /* For license and copyright information please see the LEGAL file in the code repository */ 2 3 package tcp 4 5 import ( 6 "time" 7 8 "github.com/GeniusesGroup/libgo/protocol" 9 ) 10 11 func getDuration(t time.Time) (d protocol.Duration) { 12 if !t.IsZero() { 13 d = protocol.Duration(time.Until(t)) 14 if d == 0 { 15 d = -1 // don't confuse deadline right now with no deadline 16 } 17 } 18 return 19 }