Created
February 7, 2019 07:28
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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