You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lazydocker/test/printrandom/main.go

27 lines
310 B
Go

package main
import (
"fmt"
"math/rand"
"os"
"os/signal"
"time"
)
func main() {
exitOnInterrupt()
for range time.Tick(time.Second / 3) {
fmt.Println(rand.Intn(1000))
}
}
func exitOnInterrupt() {
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
<-c
os.Exit(0)
}()
}