Skip to content

Instantly share code, notes, and snippets.

@taurpuns
Created February 7, 2019 07:28
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 taurpuns/25678c0e498b6520b732821b26650418 to your computer and use it in GitHub Desktop.
Save taurpuns/25678c0e498b6520b732821b26650418 to your computer and use it in GitHub Desktop.
A Metronome example, developed in Golang. Takes a bpm and count as input.
package main
import (
"fmt"
"log"
"os"
"strconv"
"time"
)
func main() {
bpm, err := strconv.Atoi(os.Args[1])
count, err2 := strconv.Atoi(os.Args[2])
if err != nil || err2 != nil {
log.Fatal(err)
}
times := time.Duration(bpm)
for index := 0; index < count; index++ {
fmt.Println("beep")
time.Sleep(time.Minute / times)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment