Introduced basic structure

This commit is contained in:
Simon Martens
2024-11-10 00:58:23 +01:00
parent dafa217003
commit 65f8f0d8a1
8 changed files with 193 additions and 110 deletions

16
helpers/errors.go Normal file
View File

@@ -0,0 +1,16 @@
package helpers
import (
"fmt"
"os"
)
func MaybePanic(err error, msg string) {
if err == nil {
return
}
fmt.Println(msg)
fmt.Println("Error: ", err)
os.Exit(1)
}

20
helpers/logging.go Normal file
View File

@@ -0,0 +1,20 @@
package helpers
import "fmt"
func LogOnDebug[T fmt.Stringer](object T, msg string) {
if msg != "" {
fmt.Println(msg)
}
fmt.Println(object)
}
func LogOnErr[T fmt.Stringer](object T, err error, msg string) {
if err != nil {
if msg != "" {
fmt.Println(msg)
}
fmt.Println(object)
fmt.Println("Error: ", err)
}
}