2024-01-15 15:54:53 -06:00
|
|
|
// Copyright 2024 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2023-12-30 20:48:24 -06:00
|
|
|
package log
|
|
|
|
|
2024-01-04 12:34:04 -06:00
|
|
|
// a shortcut for sleep so you don't have to always change the import lines when debugging
|
2023-12-30 20:48:24 -06:00
|
|
|
|
2024-11-07 01:23:43 -06:00
|
|
|
import (
|
2023-12-30 20:48:24 -06:00
|
|
|
"errors"
|
2024-11-07 01:23:43 -06:00
|
|
|
"os"
|
2023-12-30 20:48:24 -06:00
|
|
|
"reflect"
|
2024-11-07 01:23:43 -06:00
|
|
|
"time"
|
2023-12-30 20:48:24 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
/*
|
2024-11-07 01:23:43 -06:00
|
|
|
sleep() # you know what this does? sleeps for 1 second. yep. dump. easy.
|
|
|
|
sleep(.1) # you know what this does? yes, it sleeps for 1/10th of a second
|
2023-12-30 20:48:24 -06:00
|
|
|
*/
|
|
|
|
func Sleep(a ...any) {
|
2024-11-07 01:23:43 -06:00
|
|
|
if a == nil {
|
2023-12-30 20:48:24 -06:00
|
|
|
time.Sleep(time.Second)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-16 11:10:19 -06:00
|
|
|
Verbose("sleep", a[0])
|
2023-12-30 20:48:24 -06:00
|
|
|
|
|
|
|
switch a[0].(type) {
|
|
|
|
case int:
|
|
|
|
time.Sleep(time.Duration(a[0].(int)) * time.Second)
|
|
|
|
case float64:
|
2024-11-07 01:23:43 -06:00
|
|
|
time.Sleep(time.Duration(a[0].(float64)*1000) * time.Millisecond)
|
2023-12-30 20:48:24 -06:00
|
|
|
default:
|
2024-01-04 12:34:04 -06:00
|
|
|
Info("sleep a[0], type = ", a[0], reflect.TypeOf(a[0]))
|
2023-12-30 20:48:24 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2024-11-07 01:23:43 -06:00
|
|
|
exit() # yep. exits. I guess everything must be fine
|
|
|
|
exit(3) # I guess 3 it is then
|
|
|
|
exit("dont like apples") # ok. I'll make a note of that
|
2023-12-30 20:48:24 -06:00
|
|
|
*/
|
|
|
|
func Exit(a ...any) {
|
2024-10-12 16:32:08 -05:00
|
|
|
Error(errors.New("log.Exit()"), a...)
|
2023-12-30 20:48:24 -06:00
|
|
|
//if (a) {
|
|
|
|
// os.Exit(a)
|
|
|
|
//}
|
|
|
|
os.Exit(0)
|
|
|
|
}
|