goblin/internal/util/util.go

18 lines
412 B
Go
Raw Permalink Normal View History

2023-09-07 18:06:26 +00:00
package util
import (
"os"
)
// CreateDirectoryIfNotExists creates the specified directory if it doesn't exist.
func CreateDirectoryIfNotExists(directoryPath string) error {
// Check if the directory already exists
if _, err := os.Stat(directoryPath); os.IsNotExist(err) {
// Directory doesn't exist, create it
if err := os.MkdirAll(directoryPath, 0755); err != nil {
return err
}
}
return nil
}