Documentation
¶
Overview ¶
Package gonar implements the NAR (Nix Archive) format: a self-describing, length-prefixed serialization of a file, directory, or symlink tree.
Index ¶
- func Pack(w io.Writer, path string) error
- func PackBytes(path string) ([]byte, error)
- type Archive
- type Entry
- func (e *Entry) Contents() io.Reader
- func (e *Entry) IsDir() bool
- func (e *Entry) IsExecutable() bool
- func (e *Entry) IsFile() bool
- func (e *Entry) IsSymlink() bool
- func (e *Entry) Name() string
- func (e *Entry) SetCanonicalizeMtime(canonicalize bool)
- func (e *Entry) SetRemoveXattrs(remove bool)
- func (e *Entry) Size() int64
- func (e *Entry) String() string
- func (e *Entry) Target() string
- func (e *Entry) UnpackIn(dst string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive reads entries out of a NAR-formatted byte stream.
func NewArchive ¶
NewArchive wraps r as a NAR archive reader. By default, unpacked entries have their mtimes canonicalized to the Unix epoch and their extended attributes stripped.
func (*Archive) Entries ¶
Entries lazily parses the archive and yields each entry in depth-first order, matching the on-disk layout. Regular file contents are streamed; read them from Entry.Contents before the next iteration step. If iteration continues without consuming all contents, Entries drains the unread bytes so parsing can advance. Stopping iteration early (via break) leaves the underlying reader at an unspecified position.
func (*Archive) SetCanonicalizeMtime ¶
SetCanonicalizeMtime controls whether unpacked entries have their mtime reset to the Unix epoch.
func (*Archive) SetReadOnlyDirectories ¶
SetReadOnlyDirectories controls whether directories created during unpacking are made read-only after their contents have been written.
func (*Archive) SetRemoveXattrs ¶
SetRemoveXattrs controls whether unpacked entries have their extended attributes stripped.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
Entry is a single file, directory, or symlink parsed out of an Archive.
func (*Entry) Contents ¶
Contents returns a streaming reader for a regular file's contents. It returns nil for directories and symlinks. The reader is only valid during the current Entries iteration step.
func (*Entry) IsExecutable ¶
func (*Entry) Name ¶
Name returns the entry's path relative to the archive root, using "/" as the separator regardless of host OS.
func (*Entry) SetCanonicalizeMtime ¶
func (*Entry) SetRemoveXattrs ¶
func (*Entry) Size ¶
Size returns the length of a regular file's contents in bytes. It is 0 for directories and symlinks.
func (*Entry) String ¶
String formats the entry as a single ls-l-style line: permissions, size, and name (with "-> target" appended for symlinks).