You can wait for the OS to inform you, for example. CTRL-C from the user. Also your cron expression was for every minute, that is, only where the seconds == 1.
package main
import (
"fmt"
"os"
"os/signal"
"time"
"github.com/robfig/cron"
)
func main() {
c := cron.New()
c.AddFunc("* * * * * *", RunEverySecond)
go c.Start()
sig := make(chan os.Signal)
signal.Notify(sig, os.Interrupt, os.Kill)
<-sig
}
func RunEverySecond() {
fmt.Printf("%v\n", time.Now())
}
source
share