I need to set a task for specific time with Golang. For example job has ending time so I need to change some rows on table. I searched for it but I could only find periodic tasks with Cron. I don't want to set a cron to check database in every 5 minutes.
jasonlvhit has a library named gocron for Cron on Golang but I don't think It'll be useful on my problem.
Solved:
After @JimB's comment I checked the documentation of the time library and time.AfterFunc function can help me to solve this problem. After func function takes a Duration which must be nanosecond so it'll be useful if you create something like nanoSecondsToSecond()
time.AfterFunc(nanoSecondToSecond(10), func() {
printSometing("Mert")
})
If you define a printSomething function you can call it on closure.
func printSometing(s string) {
fmt.Println("Timer " + s)
}