This project is a command-line timer written in Golang.
The program starts a countdown from a number of seconds given as an argument, then displays the remaining time every second until it reaches zero.
fmtfor displaying the timerosfor reading command-line arguments and exiting on errorstrconvfor converting the argument to an integertimefor handling the countdown- loops and integers to make the timer work
If you do not have Golang installed, run:
sudo apt update
sudo apt install golang-goRun the program with one argument:
go run . <seconds><seconds>: number of seconds for the timer, must be a strictly positive integer
go run . 5You should see something like:
Timer: 5s
Timer: 4s
Timer: 3s
Timer: 2s
Timer: 1s
Timer: 0s
If you provide an invalid argument, the program prints an error message and exits.
Examples of invalid input:
go run .
go run . abc
go run . 0
go run . -3- The timer decreases by one second on each loop.
- The program expects exactly one argument.
- The value must be a positive non-zero integer.
Enjoy using the timer!