|
|
@ -6,16 +6,30 @@ import ( |
|
|
|
//"reflect"
|
|
|
|
//"reflect"
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func New() { |
|
|
|
func New(duration_int int, unit string) *time.Timer { |
|
|
|
|
|
|
|
|
|
|
|
timer_10s := time.NewTimer(10 * time.Second) |
|
|
|
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)
|
|
|
|
// timer_1m := time.NewTimer(1 * time.Minute)
|
|
|
|
fmt.Println("Waiting 10 seconds...") |
|
|
|
fmt.Println("Duration: ", duration_int, "Unit: ", unit, ".") |
|
|
|
<-timer_10s.C |
|
|
|
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 elapsed < ten_seconds {
|
|
|
|
//}
|
|
|
|
//}
|
|
|
|
// for
|
|
|
|
// for
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Reset |
|
|
|