mirror of
https://github.com/NotAShelf/goblin.git
synced 2024-11-22 21:31:07 +00:00
18 lines
412 B
Go
18 lines
412 B
Go
|
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
|
||
|
}
|