type Archive … type File … // 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. func Format(a *Archive) []byte { … } // ParseFile parses the named file as an archive. func ParseFile(file string) (*Archive, error) { … } // Parse parses the serialized form of an Archive. // The returned Archive holds slices of data. func Parse(data []byte) *Archive { … } var newlineMarker … var marker … var markerEnd … // findFileMarker finds the next file marker in data, // extracts the file name, and returns the data before the marker, // the file name, and the data after the marker. // If there is no next marker, findFileMarker returns before = fixNL(data), name = "", after = nil. func findFileMarker(data []byte) (before []byte, name string, after []byte) { … } // isMarker checks whether data begins with a file marker line. // If so, it returns the name from the line and the data after the line. // Otherwise it returns name == "" with an unspecified after. func isMarker(data []byte) (name string, after []byte) { … } // If data is empty or ends in \n, fixNL returns data. // Otherwise fixNL returns a new slice consisting of data with a final \n added. func fixNL(data []byte) []byte { … }