Skip to content

Instantly share code, notes, and snippets.

@seemcat
Created January 8, 2019 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seemcat/54309bd1ba5860be9e64b2a5bb33c23c to your computer and use it in GitHub Desktop.
Save seemcat/54309bd1ba5860be9e64b2a5bb33c23c to your computer and use it in GitHub Desktop.
c0d3 solved in Go
package main
import (
"time"
"fmt"
"sync"
)
func newFunc(b int, fn func()) func() {
return func() {
time.AfterFunc(time.Duration(b)*time.Second, fn)
}
}
func solution10(a, b int, fn func()) {
f := newFunc(b, fn)
time.AfterFunc(time.Duration(a)*time.Second, f)
}
func main() {
var wg sync.WaitGroup
wg.Add(2)
// not printing out because program exits soon as main finishes
fn := func() { fmt.Print("hello") }
solution10(1, 100, fn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment