github.com/zooyer/miskit@v1.0.71/utils/io.go (about)

     1  package utils
     2  
     3  import "os"
     4  
     5  func AppendFile(filename string, data []byte, perm os.FileMode) error {
     6  	f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_APPEND, perm)
     7  	if err != nil {
     8  		return err
     9  	}
    10  	_, err = f.Write(data)
    11  	if err1 := f.Close(); err == nil {
    12  		err = err1
    13  	}
    14  	return err
    15  }
    16  
    17  func Append(filename string, data []byte) error {
    18  	return AppendFile(filename, data, 0644)
    19  }