mirror of
https://github.com/kubernetes-sigs/kind.git
synced 2025-11-30 23:16:04 +07:00
17 lines
364 B
Go
17 lines
364 B
Go
package common
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// FileOnHost is a helper to create a file at path
|
|
// even if the parent directory doesn't exist
|
|
// in which case it will be created with ModePerm
|
|
func FileOnHost(path string) (*os.File, error) {
|
|
if err := os.MkdirAll(filepath.Dir(path), os.ModePerm); err != nil {
|
|
return nil, err
|
|
}
|
|
return os.Create(path)
|
|
}
|