summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-01-21 01:11:52 +0200
committerPaul Buetow <paul@buetow.org>2024-01-21 01:11:52 +0200
commit3c3034365556255a20b272c5137ede6b1a149235 (patch)
tree7141a8c25f354a6e6c3b1845ebdea7f2795d70af /main.go
parent45219497b1ae9a8ddccb4ba0884b61a9e988b489 (diff)
initial quicklogger
Diffstat (limited to 'main.go')
-rw-r--r--main.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..679afb1
--- /dev/null
+++ b/main.go
@@ -0,0 +1,47 @@
+package main
+
+import (
+ "crypto/sha256"
+ "encoding/hex"
+ "fmt"
+ "log"
+ "os"
+
+ "fyne.io/fyne/v2"
+ "fyne.io/fyne/v2/app"
+ "fyne.io/fyne/v2/container"
+ "fyne.io/fyne/v2/widget"
+)
+
+func main() {
+ myApp := app.New()
+ myWindow := myApp.NewWindow("Quick logger")
+
+ input := widget.NewMultiLineEntry()
+ input.SetPlaceHolder("Enter text here...")
+
+ button := widget.NewButton("Log text", func() {
+ content := input.Text
+ filename := fmt.Sprintf("%s.txt", getSHA256Hash(content))
+ err := os.WriteFile(filename, []byte(content), 0644)
+ if err != nil {
+ log.Println("Error writing to file:", err)
+ } else {
+ input.SetText("")
+ }
+ })
+
+ myWindow.SetContent(container.NewVBox(
+ input,
+ button,
+ ))
+ myWindow.Resize(fyne.NewSize(200, 100))
+
+ myWindow.ShowAndRun()
+}
+
+func getSHA256Hash(text string) string {
+ hasher := sha256.New()
+ hasher.Write([]byte(text))
+ return hex.EncodeToString(hasher.Sum(nil))
+}