This commit is contained in:
Jeffrey Paul 2020-09-29 16:27:16 -07:00
commit 700dcd90b1
2 changed files with 27 additions and 0 deletions

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# patterns
snippet repository. PRs welcome. doesn't need to run/compile, but cool if
it does.

23
go/timer.go Normal file
View File

@ -0,0 +1,23 @@
package main
// from https://www.youtube.com/watch?v=yeetIgNeIkc&t=1064s
import (
"log"
"time"
)
func main() {
stop := StartTimer("main")
time.Sleep(1 * time.Second)
defer stop()
}
func StartTimer(name string) func() {
t := time.Now()
log.Println(name, "started")
return func() {
d := time.Now().Sub(t)
log.Println(name, "took", d)
}
}