aboutsummaryrefslogtreecommitdiff
path: root/cmd/anubis/main.go
diff options
context:
space:
mode:
authorJason Cameron <git@jasoncameron.dev>2025-04-22 20:31:19 -0400
committerGitHub <noreply@github.com>2025-04-22 20:31:19 -0400
commit78bb67fbf79bce6abed9d4e416ca1d10ed7dc12b (patch)
tree160698d9ffa50eb2a2911b906dfa2c1feb976cf2 /cmd/anubis/main.go
parent2db4105479e5920e983b15b0341104d6e572c1ea (diff)
downloadanubis-78bb67fbf79bce6abed9d4e416ca1d10ed7dc12b.tar.xz
anubis-78bb67fbf79bce6abed9d4e416ca1d10ed7dc12b.zip
fix: improve error handling and create the json encoder once #331 (#332)
* fix: improve error handling for resource closing and JSON encoding in MakeChallenge * chore: update CHANGELOG with recent changes and improvements * refactor: simplify RenderIndex function and improve error handling --------- Signed-off-by: Jason Cameron <git@jasoncameron.dev>
Diffstat (limited to 'cmd/anubis/main.go')
-rw-r--r--cmd/anubis/main.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go
index 222e21f..fafd1b1 100644
--- a/cmd/anubis/main.go
+++ b/cmd/anubis/main.go
@@ -117,7 +117,10 @@ func setupListener(network string, address string) (net.Listener, string) {
err = os.Chmod(address, os.FileMode(mode))
if err != nil {
- listener.Close()
+ err := listener.Close()
+ if err != nil {
+ log.Printf("failed to close listener: %v", err)
+ }
log.Fatal(fmt.Errorf("could not change socket mode: %w", err))
}
}
@@ -227,12 +230,12 @@ func main() {
log.Fatalf("failed to parse and validate ED25519_PRIVATE_KEY_HEX: %v", err)
}
} else if *ed25519PrivateKeyHexFile != "" {
- hex, err := os.ReadFile(*ed25519PrivateKeyHexFile)
+ hexData, err := os.ReadFile(*ed25519PrivateKeyHexFile)
if err != nil {
log.Fatalf("failed to read ED25519_PRIVATE_KEY_HEX_FILE %s: %v", *ed25519PrivateKeyHexFile, err)
}
- priv, err = keyFromHex(string(bytes.TrimSpace(hex)))
+ priv, err = keyFromHex(string(bytes.TrimSpace(hexData)))
if err != nil {
log.Fatalf("failed to parse and validate content of ED25519_PRIVATE_KEY_HEX_FILE: %v", err)
}