itar

package module
v0.0.0-...-74c47b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

itar

This provides an iterator for archive/tar.

package main

import (
	"fmt"
	"os"

	"github.com/jonjohnsonjr/itar"
)

func main() {
	tr := tar.NewReader(os.Stdin)
	for hdr, err := range itar.Etor(tr) {
		if err != nil {
			panic(err)
		}

		fmt.Println(hdr.FileInfo().(fmt.Stringer).String())

		if n, err := io.Copy(io.Discard, tr); err != nil {
			panic(err)
		} else {
			fmt.Printf("read %d bytes\n", n)
		}
	}
}

func before() {
	tr := tar.NewReader(os.Stdin)
	for {
        hdr, err := tr.Next()
        if err != nil {
            if errors.Is(err, io.EOF) {
                break
            }

            panic(err)
        }

		fmt.Println(hdr.FileInfo().(fmt.Stringer).String())

		if n, err := io.Copy(io.Discard, tr); err != nil {
			panic(err)
		} else {
			fmt.Printf("read %d bytes\n", n)
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Etor

func Etor(tr *tar.Reader) iter.Seq2[*tar.Header, error]

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL