Skip to content

Commit

Permalink
refactor: use MkdirAll instead of Stat+Mkdir
Browse files Browse the repository at this point in the history
Signed-off-by: ludo <controlplane@spiarh.fr>
  • Loading branch information
spiarh committed Jan 5, 2024
1 parent 7c28525 commit 0c12591
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/simulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"errors"
"log/slog"
"os"
"path/filepath"
Expand Down Expand Up @@ -177,11 +176,9 @@ func main() {

func mkDirsIfNotExist(dirs ...string) {
for _, dir := range dirs {
if _, err := os.Stat(dir); errors.Is(err, os.ErrNotExist) {
if err := os.Mkdir(dir, ownerReadWriteExecute); err != nil {
slog.Error("failed to bundle directory", "dir", dir, "error", err)
os.Exit(1)
}
if err := os.MkdirAll(dir, ownerReadWriteExecute); err != nil {
slog.Error("failed to bundle directory", "dir", dir, "error", err)
os.Exit(1)
}
}
}

0 comments on commit 0c12591

Please sign in to comment.