22 lines
305 B
Go
22 lines
305 B
Go
package utils
|
|
|
|
import "os"
|
|
|
|
func WriteToFile(filename, content string) {
|
|
f, err := os.Create(filename)
|
|
defer CloseFile(f)
|
|
_, err = f.WriteString(content)
|
|
MustCheck(err)
|
|
}
|
|
|
|
func CloseFile(f *os.File) {
|
|
err := f.Close()
|
|
MustCheck(err)
|
|
}
|
|
|
|
func MustCheck(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|