parent
cdc49b7138
commit
d22b38ff2e
|
@ -6,6 +6,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func lineInFile(name string, lookFor string) bool {
|
func lineInFile(name string, lookFor string) bool {
|
||||||
|
@ -37,11 +38,19 @@ func lineInFile(name string, lookFor string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFile(name string, content string) error {
|
func createFile(name string, content string) error {
|
||||||
|
// make sure file directory exists
|
||||||
|
if err := os.MkdirAll(filepath.Dir(name), 0775); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the file
|
||||||
f, err := os.Create(name)
|
f, err := os.Create(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
|
// write file content
|
||||||
_, err = f.WriteString(fmt.Sprintf("%s\n", content))
|
_, err = f.WriteString(fmt.Sprintf("%s\n", content))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue