// WriteFile writes 'data' to the file 'filename' with the given permissions. func WriteFile(filename string, data []byte, perm os.FileMode) error { a := afero.Afero{ Fs: AppFs, } return a.WriteFile(filename, data, perm) }
// ReadFile returns the contents of `filename`. func ReadFile(filename string) (string, error) { a := afero.Afero{ Fs: AppFs, } fileBytes, err := a.ReadFile(filename) if err != nil { return "", err } return string(fileBytes), nil }
func fileContents(file string) (string, error) { a := afero.Afero{ Fs: appFs, } contents, err := a.ReadFile(file) if err != nil { return "", err } return string(contents), nil }
func writeTo(file string, message string) error { a := afero.Afero{ Fs: appFs, } f, err := a.OpenFile(file, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0666) if err != nil { logrus.WithError(err).Errorf("Couldn't open %s for writing", file) return err } defer f.Close() _, err = f.WriteString(message) return err }
func overwrite(file string, message string) error { a := afero.Afero{ Fs: appFs, } return a.WriteFile(file, []byte(message), 0666) }