arnaucube
arnaucube/padArchiverPublic Self-hosted repository
padArchiver/file.go
file.goRaw
 1package padArchiver
 2
 3import (
 4	"io/ioutil"
 5)
 6
 7//AddLineToFile adds a line in the beginning of the file
 8func AddLineToFile(path string, line string) error {
 9	fileBytes, err := ioutil.ReadFile(path)
10	if err != nil {
11		return err
12	}
13	content := string(fileBytes)
14	r := line + "\n\n"
15	r = r + content
16
17	err = ioutil.WriteFile(path, []byte(r), 0644)
18	if err != nil {
19		return err
20	}
21	return nil
22}