Documentation
¶
Overview ¶
Package textar encodes a file list (key-value slice) into a human editable text file and vice versa. This is inspired by https://pkg.go.dev/golang.org/x/tools/txtar but this format can encode any content perfectly without issues. Go's txtar doesn't handle newlines and content containing txtar markers well. In textar each file is encoded via "[SEP] [NAME]\n[CONTENT]\n". SEP is two or more = signs. The first SEP can be arbitrary length, the rest must be the same length. The first line beginning with == determines the separator length. The dynamic SEP-length makes it possible to encode and decode anything perfectly. This is the main advantage over Go's txtar. Furthermore anything before the first SEP is a free form comment. Example:
Some comments here. === file1 file1 content. === file2 file2 content. == file3 this is a textar within textar.
The separator here is === so this textar contains file1 and file2. file3 is not part of the main textar, it just shows that file2 could be a textar itself.
The Archive.Format function automatically picks a separator length that is unique and won't conflict with existing file values. Use Parse to parse it back.
See https://github.com/ypsu/textar/blob/main/example/seq.textar for a longer example. See the testdata directory of https://github.com/ypsu/pkgtrim for a more realistic example.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Archive ¶ added in v0.250524.0
An Archive is a collection of files.
func Parse ¶
Parse parses the serialized form of an Archive. The returned Archive holds slices of data.
func (*Archive) FS ¶ added in v0.250524.0
FS returns an object implementing io/fs.FS built from the contents of an archive. This is a helper function for tests.
Directories
¶
Path | Synopsis |
---|---|
bin
|
|
textar
textar converts to and extracts from textar files.
|
textar converts to and extracts from textar files. |
The seq command demonstrates the usage of the textar library, see seq.textar for the details.
|
The seq command demonstrates the usage of the textar library, see seq.textar for the details. |