Standard library / archive/tar

archive/tar.Writer

Stateful sequential archive writer. Supply a header and matching payload, then finalize. Expected stdout: '1024\n'.

Formal Syntax & Structure

go syntaxgo
type Writer struct {  // Has unexported fields.}

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)  var out *tar.Writer = w  must(out.Close())  fmt.Println(b.Len())}
Go Reference