Movatterモバイル変換


[0]ホーム

URL:


txtar

packagestandard library
go1.25.5Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:4Imported by:0

Details

Repository

cs.opensource.google/go/go

Links

Documentation

Overview

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 likesymbolic 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 enclosedfile 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

funcFormat

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.

Types

typeArchive

type Archive struct {Comment []byteFiles   []File}

An Archive is a collection of files.

funcParse

func Parse(data []byte) *Archive

Parse parses the serialized form of an Archive.The returned Archive holds slices of data.

funcParseFile

func ParseFile(filestring) (*Archive,error)

ParseFile parses the named file as an archive.

typeFile

type File struct {Namestring// name of file ("foo/bar.txt")Data []byte// text content of file}

A File is a single file in an archive.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp