Skip to content

Commit f7e48db

Browse files
committed
Add Create Directory
1 parent 3ece34b commit f7e48db

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ func getStorageDirectory() string {
1818

1919
func ensureDirectory() string {
2020
path := getStorageDirectory()
21+
os.MkdirAll(path, os.ModePerm)
2122
return path
2223
}
2324

2425
func list() {
25-
path := getStorageDirectory()
26+
path := ensureDirectory()
2627
files, err := ioutil.ReadDir(path)
2728
if err != nil {
2829
log.Fatal(err)
@@ -51,7 +52,7 @@ func set(key, value string) {
5152
}
5253

5354
func get(key string) {
54-
keyFile := filepath.Join(getStorageDirectory(), key)
55+
keyFile := filepath.Join(ensureDirectory(), key)
5556
f, err := os.Open(keyFile)
5657

5758
if err != nil {

0 commit comments

Comments
 (0)