func SleepWithGranularity(duration time.Duration, granularity time.Duration) {
	if duration <= granularity {
		time.Sleep(duration)
		return
	}
	start := time.Now().Unix()
	for {
		time.Sleep(granularity)
		elapsed := time.Duration(time.Now().Unix()-start) * time.Second
		if elapsed < 0 || elapsed > duration {
			break
		} else if elapsed > duration-granularity {
			time.Sleep(duration - elapsed)
			break
		}
	}
}
SleepWithGranularity - sleeps for the given amount of time, with the given granularity;
doesn't pause if the system goes to hibernation
package clocksmith
import "time"
const (
	DefaultGranularity = 5 * time.Second
)