package txtar
Import Path
internal/txtar (on go.dev)
Dependency Relation
imports 4 packages, and imported by 2 packages
Involved Source Files
Package txtar implements a trivial text-based file archive format.
The goals for the format are:
- be trivial enough to create and edit by hand.
- be able to store trees of text files describing go command test cases.
- diff nicely in git history and code reviews.
Non-goals include being a completely general archive format,
storing binary data, storing file modes, storing special files like
symbolic links, and so on.
# Txtar format
A txtar archive is zero or more comment lines and then a sequence of file entries.
Each file entry begins with a file marker line of the form "-- FILENAME --"
and is followed by zero or more file content lines making up the file data.
The comment or file content ends at the next file marker line.
The file marker line must begin with the three-byte sequence "-- "
and end with the three-byte sequence " --", but the enclosed
file name can be surrounding by additional white space,
all of which is stripped.
If the txtar file is missing a trailing newline on the final line,
parsers should consider a final newline to be present anyway.
There are no possible syntax errors in a txtar archive.
Package-Level Type Names (total 2)
An Archive is a collection of files.
Comment []byte
Files []File
func Parse(data []byte) *Archive
func ParseFile(file string) (*Archive, error)
func Format(a *Archive) []byte
A File is a single file in an archive.
// text content of file
// name of file ("foo/bar.txt")
Package-Level Functions (total 3)
Format returns the serialized form of an Archive.
It is assumed that the Archive data structure is well-formed:
a.Comment and all a.File[i].Data contain no file marker lines,
and all a.File[i].Name is non-empty.
Parse parses the serialized form of an Archive.
The returned Archive holds slices of data.
ParseFile parses the named file as an archive.
The pages are generated with Golds v0.6.9-preview. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |