neo-go/pkg/io/fileWriter.go
AnnaShaleva aefb6f9fee *: fix tests failing due to path.Join usage
Solution:
Use `file/filepath` package to construct expected path. This package is OS-aware, see https://github.com/golang/go/issues/30616.
2021-11-29 11:11:09 +03:00

18 lines
367 B
Go

package io
import (
"fmt"
"os"
"path/filepath"
)
// MakeDirForFile creates directory provided in filePath.
func MakeDirForFile(filePath string, creator string) error {
fileName := filePath
dir := filepath.Dir(fileName)
err := os.MkdirAll(dir, os.ModePerm)
if err != nil {
return fmt.Errorf("could not create dir for %s: %w", creator, err)
}
return nil
}