ctdo.de/file.go

23 lines
371 B
Go
Raw Normal View History

package main
import (
"io/ioutil"
"os"
)
func fileRead(src string) string {
content, err := ioutil.ReadFile(src)
errorPanic(err)
return string(content)
}
func fileAddLine(input string, filepath string) {
file, err := os.OpenFile(filepath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
errorPanic(err)
_, err = file.WriteString(input + "\n")
errorPanic(err)
}