You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
462 B
Go
17 lines
462 B
Go
package conf
|
|
|
|
import "time"
|
|
|
|
const minDuration = 100 * time.Microsecond
|
|
|
|
// CheckedDuration returns the duration that guaranteed to be greater than 100us.
|
|
// Why we need this is because users sometimes intend to use 500 to represent 500ms.
|
|
// In config, duration less than 100us should always be missing ms etc.
|
|
func CheckedDuration(duration time.Duration) time.Duration {
|
|
if duration > minDuration {
|
|
return duration
|
|
}
|
|
|
|
return duration * time.Millisecond
|
|
}
|