teleport_devops_challenge/timer/timer.go
Mike Holloway 8e2f4e3db8 On branch timer
Changes to be committed:
	modified:   main.go
		Adding use of time package directly
	modified:   timer/timer.go
		Simplifying this away.
2021-06-26 17:07:48 -04:00

36 lines
792 B
Go

package timer
import (
"fmt"
"time"
//"reflect"
)
func New(duration_int int, unit string) *time.Timer {
start := time.NewTimer(0)
duration := time.Duration(duration_int)
// fmt.Println(reflect.TypeOf(duration))
// timer_10s := time.NewTimer(10 * time.Second)
// timer_1m := time.NewTimer(1 * time.Minute)
fmt.Println("Duration: ", duration_int, "Unit: ", unit, ".")
if unit == "Second" {
start = time.NewTimer(duration * time.Second)
} else if unit == "Minute" {
start = time.NewTimer(duration * time.Minute)
} else {
fmt.Println("Unit not recognized.")
}
fmt.Println("Waiting ", duration_int, " ", unit, ".")
if start.Stop() {
<-start.C
fmt.Println("Done waiting ", duration_int, " ", unit, "!")
}
return start
// for elapsed < ten_seconds {
//}
// for
}
func Reset