summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2024-06-05 16:45:30 -0600
committermo khan <mo@mokhan.ca>2024-06-05 16:45:30 -0600
commit8f77a3bbcd298e3839e8276276ee4bcd2a826c3b (patch)
treefcefcb2d4ad28447261284f00a41d0a7430e9520
parent620b3a0be81070872c8c990a1aecdc0e661dc90e (diff)
Create directory if it does not exist
-rw-r--r--pkg/db/client.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkg/db/client.go b/pkg/db/client.go
index 39d3f9e..a656505 100644
--- a/pkg/db/client.go
+++ b/pkg/db/client.go
@@ -1,12 +1,22 @@
package db
+import (
+ "os"
+ "path/filepath"
+
+ "github.com/xlgmokha/x/pkg/x"
+)
+
type Storage[T any] struct {
dir string
}
func New[T any](dir string) *Storage[T] {
+ fullPath := x.Must(filepath.Abs(dir))
+ x.Check(os.MkdirAll(fullPath, 0700))
+
return &Storage[T]{
- dir: dir,
+ dir: fullPath,
}
}