Added counter exercise

This commit is contained in:
raul 2024-01-31 07:43:11 +00:00
parent fde585b7ad
commit 4913df663a
2 changed files with 38 additions and 0 deletions

3
golangr/counter/go.mod Normal file
View File

@ -0,0 +1,3 @@
module counter
go 1.21.6

35
golangr/counter/main.go Normal file
View File

@ -0,0 +1,35 @@
package main
import (
"fmt"
"os"
"time"
)
var delay float64
var num int16
func clear() {
fmt.Print("\033[H\033[2J")
}
func main() {
if len(os.Args) != 2 {
fmt.Println("Not enough arguments")
os.Exit(1)
}
fmt.Println("How much delay in seconds?")
timer, err := fmt.Scanln(num)
_ = timer
if err != nil {
fmt.Println(err)
}
for i := 0; true; i++ {
time.Sleep(100 * time.Millisecond)
clear()
fmt.Println(i)
}
}