Golang archive/tar.Write() function example
package archive/tar
Write writes to the current entry in the tar archive. Write returns the error ErrWriteTooLong if more than hdr.Size bytes are written after WriteHeader.
tar.Write() usage example
for _, file := range files {
headerinfo := &tar.Header{
Name: file.Name,
Size: int64(len(file.Body)),
}
if err := tarwriter.WriteHeader(headerinfo); err != nil {
fmt.Println(err)
}
if _, err := tarwriter.Write([]byte(file.Body)); err != nil {
fmt.Println(err)
}
}
Reference :
Advertisement
Something interesting
Tutorials
+7.9k Golang : Grayscale Image
+5.7k Unix/Linux/MacOSx : Get local IP address
+33.6k Golang : How to check if slice or array is empty?
+17.6k Golang : Parse date string and convert to dd-mm-yyyy format
+12.3k Golang : Display list of countries and ISO codes
+7.4k Golang : Accessing dataframe-go element by row, column and name example
+19k Golang : Padding data for encryption and un-padding data for decryption
+8.5k Linux/Unix : fatal: the Postfix mail system is already running
+19.6k Golang : Close channel after ticker stopped example
+10.5k RPM : error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
+5.9k AWS S3 : Prevent Hotlinking policy