-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlifecycle.go
More file actions
84 lines (69 loc) · 2.73 KB
/
lifecycle.go
File metadata and controls
84 lines (69 loc) · 2.73 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* -----------------------------------------------------------------
* L o r d O f S c r i p t s (tm)
* Copyright (C)2025 Dídimo Grimaldo T.
* photoQ
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* General Application Lifecycle utilities
*-----------------------------------------------------------------*/
package photoq
import (
"fmt"
"os"
)
/* ----------------------------------------------------------------
* G l o b a l s
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* I n t e r f a c e s
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* P u b l i c T y p e s
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* P r i v a t e T y p e s
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* I n i t i a l i z e r
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* C o n s t r u c t o r s
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* P u b l i c M e t h o d s
*-----------------------------------------------------------------*/
/**
* DESCR
* @params a (type):
* @returns
*/
/* ----------------------------------------------------------------
* P r i v a t e M e t h o d s
*-----------------------------------------------------------------*/
/* ----------------------------------------------------------------
* F u n c t i o n s
*-----------------------------------------------------------------*/
/**
* Death of an application by outputting a good-bye and setting
* the OS exit code.
*/
func Die(exitCode int, message string) {
fmt.Println("\n", "\t💀 x 💀 x 💀\n\t", message, "\n\tExit code: ", exitCode)
os.Exit(exitCode)
}
func DieWithError(exitCode int, err error) {
fmt.Printf("\n\t💀 x 💀 x 💀\n\t(%T)\n\t%s\n\tExit code: %d\n", err, err, exitCode)
os.Exit(exitCode)
}
func Assert(condition bool, warnMessage string) {
const UC_RED_EXCLAMATION = rune(0x2757) // Dingbats
if condition {
fmt.Printf("\n\t%c Assertion Failed:\n\t%s\n", UC_RED_EXCLAMATION, warnMessage)
}
}
func AssertOrDie(condition bool, deathMessage string, exitCode int) {
const UC_RED_EXCLAMATION = rune(0x2757) // Dingbats
if condition {
fmt.Printf("\n\t%c Assertion Failed:", UC_RED_EXCLAMATION)
Die(exitCode, deathMessage)
}
}