From 8f77a3bbcd298e3839e8276276ee4bcd2a826c3b Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 5 Jun 2024 16:45:30 -0600 Subject: Create directory if it does not exist --- pkg/db/client.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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, } } -- cgit v1.2.3