You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

22 lines
392 B

package padArchiver
import (
"io/ioutil"
)
//AddLineToFile adds a line in the beginning of the file
func AddLineToFile(path string, line string) error {
fileBytes, err := ioutil.ReadFile(path)
if err != nil {
return err
}
content := string(fileBytes)
r := line + "\n\n"
r = r + content
err = ioutil.WriteFile(path, []byte(r), 0644)
if err != nil {
return err
}
return nil
}