...
Package txtar
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.
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.
In the call graph viewer below, each node
is a function belonging to this package
and its children are the functions it
calls—perhaps dynamically.
The root nodes are the entry points of the
package: functions that may be called from
outside the package.
There may be non-exported or anonymous
functions among them if they are called
dynamically from another package.
Click a node to visit that function's source code.
From there you can visit its callers by
clicking its declaring func
token.
Functions may be omitted if they were
determined to be unreachable in the
particular programs or tests that were
analyzed.
func Format(a *Archive) []byte
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.
type Archive struct {
Comment []byte
Files []File
}
An Archive is a collection of files.
func Parse(data []byte) *Archive
Parse parses the serialized form of an Archive.
The returned Archive holds slices of data.
func ParseFile(file string) (*Archive, error)
ParseFile parses the named file as an archive.
type File struct {
Name string
Data []byte
}
A File is a single file in an archive.