handle errors, yeet deprecated dep, & add license

Amolith created

Change summary

README.md |  6 ++++++
justfile  | 27 +++++++++++++++++++++++++++
main.go   | 16 +++++++++++++---
3 files changed, 46 insertions(+), 3 deletions(-)

Detailed changes

README.md 🔗

@@ -1,3 +1,9 @@
+<!--
+SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+
+SPDX-License-Identifier: CC0-1.0
+-->
+
 # p2c
 
 [![Go report card status][goreportcard-badge]][goreportcard]

justfile 🔗

@@ -0,0 +1,27 @@
+# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
+#
+# SPDX-License-Identifier: CC0-1.0
+
+default: reuse lint test staticcheck
+
+reuse:
+    reuse lint
+
+lint:
+    # Linting Go code
+    go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
+    golangci-lint run
+
+test:
+    # Running tests
+    go test -v ./...
+
+staticcheck:
+    # Performing static analysis
+    go install honnef.co/go/tools/cmd/staticcheck@latest
+    staticcheck ./...
+
+clean:
+    # Cleaning up
+    rm -rf p2c
+

main.go 🔗

@@ -11,7 +11,6 @@ import (
 	"image"
 	"image/color"
 	"image/png"
-	"io/ioutil"
 	"os"
 	"strings"
 
@@ -172,7 +171,12 @@ func main() {
 			layout.Rigid(layout.Spacer{Height: 50}.Layout),
 		)
 	})
-	w.Frame(gtx.Ops)
+	err = w.Frame(gtx.Ops)
+	if err != nil {
+		fmt.Println("Error: Could not render GUI")
+		fmt.Println(err)
+		os.Exit(1)
+	}
 	img := image.NewRGBA(image.Rectangle{Max: sz})
 	err = w.Screenshot(img)
 	if err != nil {
@@ -186,7 +190,13 @@ func main() {
 		fmt.Println(err)
 		os.Exit(1)
 	}
-	ioutil.WriteFile(*flagOutput, buf.Bytes(), 0o644)
+	// Write the image to a file
+	err = os.WriteFile(*flagOutput, buf.Bytes(), 0o644)
+	if err != nil {
+		fmt.Println("Error: Could not write image to file")
+		fmt.Println(err)
+		os.Exit(1)
+	}
 
 	os.Exit(0)
 }