engine/utils/file.go

21 lines
401 B
Go
Raw Permalink Normal View History

2024-02-11 01:31:01 +08:00
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
}