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