Documentation
¶
Overview ¶
package gotar defines a format for self-extracting executables used by gotar.
Format: N bytes of decoder app code M bytes of gzipped tar file data L bytes of json data 32 bytes of footer
The footer consists of 4 big-endian 64 byte numbers that let you decode the file:
1. N the length of the app 2. M the length of the gzipped tar file 3. L the length of the json data 4. 0x00 0x00 0x00 0x00 0xDE 0xF1 0xA7 0xED an arbitrary signature to identify the file type.
It is currently an error for any of these fields to be 0, both tar data and json data must be present.
The format is intended for self-extracting executables created by gotar.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFormat = fmt.Errorf("invalid gotar file")
Returned when Read() is called on an invalid archive
var SIGNATURE = int64(0xDEF1A7ED)
The signature of a gotar executable. It looks kind of like DEFLATED if you squint hard.
Functions ¶
This section is empty.
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
An Archive opened for reading.
func Read ¶
func Read(f io.ReadSeeker) (*Archive, error)
Read an archive from a file. It is an error to seek or read from the file while it belongs to a gotar.Archive
func (*Archive) NextFile ¶
NextFile reads the next file from the embedded tar file. It returns the tar header and the file contents or an error. Once the end of the tar file is reached, io.EOF will be returned. The caller must read the entire returned Reader before calling this function again
func (*Archive) ReadMetaData ¶
ReadMetaData decodes the metaData stored within the gotarred archive.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
An Archive Writer. Users should always call WriteDecoder, then WriteFile then WriteMetaData, then finally Close.
func (*Writer) Close ¶
Close closes the archive and finishes writing the metaData and footer. It does not close the underlying io.Writer.
func (*Writer) WriteDecoder ¶
WriteDecoder writes the decoder executable into the archive. It should be a binary that will run on the target system.
func (*Writer) WriteFile ¶
WriteFile adds a file into the archive with the path set relativeTo the given directory. It is an error to call WriteFile before WriteDecoder or after Close.
func (*Writer) WriteMetaData ¶
func (writer *Writer) WriteMetaData(metaData interface{})
WriteMetaData adds MetaData to the archive. Any type that can be serialized to be JSON may be used.