Skip to content

Commit

Permalink
Add Create Directory
Browse files Browse the repository at this point in the history
  • Loading branch information
st0le committed Feb 11, 2021
1 parent 3ece34b commit f7e48db
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ func getStorageDirectory() string {

func ensureDirectory() string {
path := getStorageDirectory()
os.MkdirAll(path, os.ModePerm)
return path
}

func list() {
path := getStorageDirectory()
path := ensureDirectory()
files, err := ioutil.ReadDir(path)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -51,7 +52,7 @@ func set(key, value string) {
}

func get(key string) {
keyFile := filepath.Join(getStorageDirectory(), key)
keyFile := filepath.Join(ensureDirectory(), key)
f, err := os.Open(keyFile)

if err != nil {
Expand Down

0 comments on commit f7e48db

Please sign in to comment.