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

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