aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go6
-rw-r--r--misc.go13
2 files changed, 12 insertions, 7 deletions
diff --git a/main.go b/main.go
index 4f6243e..edfcbf2 100644
--- a/main.go
+++ b/main.go
@@ -73,8 +73,7 @@ func main() {
e(setup_database())
log.Printf("Setting up templates\n")
- tmpl, err = template.ParseGlob("tmpl/*")
- e(err)
+ tmpl = er(template.ParseGlob("tmpl/*"))
if config.Static {
log.Printf("Registering static handle\n")
@@ -95,8 +94,7 @@ func main() {
config.Listen.Net,
config.Listen.Addr,
)
- l, err := net.Listen(config.Listen.Net, config.Listen.Addr)
- e(err)
+ l := er(net.Listen(config.Listen.Net, config.Listen.Addr))
if config.Listen.Proto == "http" {
log.Printf("Serving http\n")
diff --git a/misc.go b/misc.go
index 73e3b07..70e5a4f 100644
--- a/misc.go
+++ b/misc.go
@@ -25,12 +25,19 @@ import (
"encoding/base64"
)
-func e(e error) {
- if e != nil {
- panic(e)
+func e(err error) {
+ if err != nil {
+ panic(err)
}
}
+func er[v_t any](v v_t, err error) v_t {
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
/*
* Generate a random url-safe string.
* Note that the "len" parameter specifies the number of bytes taken from the