2019-02-25 22:44:14 +00:00
|
|
|
package fileutils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2019-03-17 18:26:35 +00:00
|
|
|
// UpdateFile appends a byte slice to a file
|
2019-02-25 22:44:14 +00:00
|
|
|
func UpdateFile(filename string, data []byte) error {
|
|
|
|
|
|
|
|
f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
|
|
|
|
|
|
|
dataWNewline := append(data, []byte("\n")...)
|
|
|
|
|
|
|
|
_, err = f.Write(dataWNewline)
|
|
|
|
err = f.Close()
|
|
|
|
return err
|
|
|
|
}
|