Skip to content

proposal: archive/tar: add iterator form of (&Reader).Next() #68062

Open
@sivchari

Description

@sivchari

Proposal Details

In Go 1.23, we can use range-over-func a.k.a iterator and developers propose to apply for the package into some packages.

For instance, the following issues are easy to know what kind of content are proposed.
#61897
#64341

This proposal is similar with above it.
I think it's good to apply for archive/tar, too.

func (tr *Reader) NextIter() iter.Seq2[*Header, error] {
	return func(yield func(*Header, error) bool) {
		hdr, err := tr.Next()
		if err == io.EOF {
			return
		}
		if !yield(hdr, err) {
			return
		}
	}
}

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions