Standard library / archive/tar
archive/tar.Writer.Close()
Finalize TAR with padding and end markers; underlying writer stays open. Missing payload bytes cause an error. Expected stdout: '1024\n'.
Formal Syntax & Structure
go syntaxgo
func (tw *Writer) Close() errorReturn Value
error
Nil on success, otherwise operation error.
Working Example
Example Snippetgo
package main
import ( "archive/tar" "bytes" "fmt")
func must(e error) { if e != nil { panic(e) }}
func main() { var b bytes.Buffer; w := tar.NewWriter(&b); must(w.Close()); fmt.Println(b.Len()) }