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.

21 lines
335 B

  1. package padArchiver
  2. import (
  3. "io/ioutil"
  4. )
  5. func AddLineToFile(path string, line string) error {
  6. fileBytes, err := ioutil.ReadFile(path)
  7. if err != nil {
  8. return err
  9. }
  10. content := string(fileBytes)
  11. r := line + "\n\n"
  12. r = r + content
  13. err = ioutil.WriteFile(path, []byte(r), 0644)
  14. if err != nil {
  15. return err
  16. }
  17. return nil
  18. }