summaryrefslogtreecommitdiff
path: root/io.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-05-05 15:43:29 +0300
committerPaul Buetow <paul@buetow.org>2024-05-05 15:43:29 +0300
commitf173d052d3f8679716862d233d8751f67d3b197c (patch)
treebfb1e7ca88b669cac319c78aa5c2ebbd737818f1 /io.go
parent2e1e698f3232d72f441bbac7d4bc2c2b29accaf8 (diff)
can retrieve JSON payload
Diffstat (limited to 'io.go')
-rw-r--r--io.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/io.go b/io.go
new file mode 100644
index 0000000..4bf795f
--- /dev/null
+++ b/io.go
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "os"
+ "path/filepath"
+)
+
+func saveFile(filePath string, bytes []byte) error {
+ dir := filepath.Dir(filePath)
+ if _, err := os.Stat(dir); os.IsNotExist(err) {
+ if err := os.MkdirAll(dir, 0755); err != nil {
+ return err
+ }
+ }
+ return os.WriteFile(filePath, bytes, 0644)
+}