Golang archive/tar.WriteHeader() function example
package archive/tar
WriteHeader writes headerinfo and prepares to accept the file's contents. WriteHeader calls Flush if it is not the first header. Calling after a Close will return ErrWriteAfterClose.
tar.WriteHeader() 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.5k Golang : Detect sample rate, channels or latency with PortAudio
+5.4k Python : Delay with time.sleep() function example
+11.9k Golang : Convert decimal number(integer) to IPv4 address
+5k Golang : Get a list of crosses(instruments) available to trade from Oanda account
+4.3k Javascript : How to show different content with noscript?
+12.3k Golang : Display list of countries and ISO codes
+13.2k CodeIgniter : "Fatal error: Cannot use object of type stdClass as array" message
+29.2k Golang : missing Git command
+7.6k Golang : Set horizontal, vertical scroll bars policies and disable interaction on Qt image
+13.6k Golang : Strings comparison
+11.6k Swift : Convert (cast) Float to String
+10k Golang : Get escape characters \u form from unicode characters