21 lines
401 B
Go
21 lines
401 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"io"
|
||
|
"os"
|
||
|
)
|
||
|
|
||
|
func StringToFile(path, content string) error {
|
||
|
startF, err := os.Create(path)
|
||
|
if err != nil {
|
||
|
return errors.New("os.Create create file " + path + " error:" + err.Error())
|
||
|
}
|
||
|
defer startF.Close()
|
||
|
_, err = io.WriteString(startF, content)
|
||
|
if err != nil {
|
||
|
return errors.New("io.WriteString to " + path + " error:" + err.Error())
|
||
|
}
|
||
|
return nil
|
||
|
}
|