Added ability to input custom delay
This commit is contained in:
parent
b93f7e445e
commit
4b34de5781
|
@ -3,10 +3,11 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var delay float64
|
var delay time.Duration
|
||||||
var num int16
|
var num int16
|
||||||
|
|
||||||
func clear() {
|
func clear() {
|
||||||
|
@ -14,22 +15,20 @@ func clear() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
if len(os.Args) != 2 {
|
if len(os.Args) != 2 {
|
||||||
fmt.Println("Not enough arguments")
|
fmt.Println("Usage: ./counter 1000 (measured in miliseconds)")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("How much delay in seconds?")
|
delay, err := strconv.Atoi(os.Args[1])
|
||||||
timer, err := fmt.Scanln(num)
|
|
||||||
_ = timer
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Printf("\nERROR:\n%v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; true; i++ {
|
for i := 0; true; i++ {
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
clear()
|
clear()
|
||||||
fmt.Println(i)
|
fmt.Println(i)
|
||||||
|
time.Sleep(time.Duration(delay) * time.Millisecond)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue