summaryrefslogtreecommitdiff
path: root/sleep.go
blob: 17a6243b57962e871e06a9d8cf5b53c53653bfe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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.

package log

// a shortcut for sleep so you don't have to always change the import lines when debugging

import 	(
	"os"
	"time"
	"errors"
	"reflect"
)

/*
	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
*/
func Sleep(a ...any) {
	if (a == nil) {
		time.Sleep(time.Second)
		return
	}

	Verbose("sleep", a[0])

	switch a[0].(type) {
	case int:
		time.Sleep(time.Duration(a[0].(int)) * time.Second)
	case float64:
		time.Sleep(time.Duration(a[0].(float64) * 1000) * time.Millisecond)
	default:
		Info("sleep a[0], type = ", a[0], reflect.TypeOf(a[0]))
	}
}

/*
	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
*/
func Exit(a ...any) {
	Error(errors.New("log.Exit()"), a)
	//if (a) {
	//	os.Exit(a)
	//}
	os.Exit(0)
}