Checking if a value is within a time range
For example,

package main

import (
    "fmt"
    "time"
)

func IsInTimeRange(tvalue int32, timeout int) bool {
    delta := int(time.Now().Unix() - int64(tvalue))
    return -timeout &lt; delta &amp;&amp; delta &lt; timeout
}

func main() {}


tvalue int32 will overflow in year 2038, change it to tvalue int64.

package main

import "time"

func IsInTimeRange(tvalue int64, timeout int) bool {
    delta := int(time.Now().Unix() - tvalue)
    return -timeout &lt; delta &amp;&amp; delta &lt; timeout
}

func main() {}