Skip to content

Instantly share code, notes, and snippets.

@packrat386
Created April 4, 2018 14:30
Show Gist options
  • Save packrat386/2c9bd61033126da6d7b79dca8b40fe33 to your computer and use it in GitHub Desktop.
Save packrat386/2c9bd61033126da6d7b79dca8b40fe33 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
var access func() int
func init() {
i := 0
t := time.After(100 * time.Millisecond)
access = func() int {
select {
case <-t:
i++
t = time.After(100 * time.Millisecond)
return i
default:
return i
}
}
}
func main() {
for {
fmt.Println(access())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment