package main import ( "log" "time" ) func f() { defer timeoutCheck("f slow", time.Now()) time.Sleep(time.Second) } func timeoutCheck(tag string, start time.Time) { dis := time.Since(start).Seconds() if dis > 1 { log.Println(tag, dis, "s") } } func main() { f() }