func parsePAX(r io.Reader) (map[string]string, error) {
	buf, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}

	// For GNU PAX sparse format 0.0 support.
	// This function transforms the sparse format 0.0 headers into sparse format 0.1 headers.
	var sparseMap bytes.Buffer

	headers := make(map[string]string)
	// Each record is constructed as
	//     "%d %s=%s\n", length, keyword, value
	for len(buf) > 0 {
		// or the header was empty to start with.
		var sp int
		// The size field ends at the first space.
		sp = bytes.IndexByte(buf, ' ')
		if sp == -1 {
			return nil, ErrHeader
		}
		// Parse the first token as a decimal integer.
		n, err := strconv.ParseInt(string(buf[:sp]), 10, 0)
		if err != nil {
			return nil, ErrHeader
		}
		// Extract everything between the decimal and the n -1 on the
		// beginning to eat the ' ', -1 on the end to skip the newline.
		var record []byte
		record, buf = buf[sp+1:n-1], buf[n:]
		// The first equals is guaranteed to mark the end of the key.
		// Everything else is value.
		eq := bytes.IndexByte(record, '=')
		if eq == -1 {
			return nil, ErrHeader
		}
		key, value := record[:eq], record[eq+1:]

		keyStr := string(key)
		if keyStr == paxGNUSparseOffset || keyStr == paxGNUSparseNumBytes {
			// GNU sparse format 0.0 special key. Write to sparseMap instead of using the headers map.
			sparseMap.Write(value)
			sparseMap.Write([]byte{','})
		} else {
			// Normal key. Set the value in the headers map.
			headers[keyStr] = string(value)
		}
	}
	if sparseMap.Len() != 0 {
		// Add sparse info to headers, chopping off the extra comma
		sparseMap.Truncate(sparseMap.Len() - 1)
		headers[paxGNUSparseMap] = sparseMap.String()
	}
	return headers, nil
}
// parsePAX parses PAX headers.
// If an extended header (type 'x') is invalid, ErrHeader is returned
parsePAX parses PAX headers.
If an extended header (type 'x') is invalid, ErrHeader is returned
// parsePAX parses PAX headers . // If an extended header ( type ' x ' ) is invalid ErrHeader is returned
func parsePAX(r io.Reader) (map[string]string, error) {
	buf, err := ioutil.ReadAll(r)
	if err != nil {
		return nil, err
	}
	var sparseMap bytes.Buffer
	headers := make(map[string]string)
	for len(buf) > 0 {
		var sp int
		sp = bytes.IndexByte(buf, ' ')
		if sp == -1 {
			return nil, ErrHeader
		}
		n, err := strconv.ParseInt(string(buf[:sp]), 10, 0)
		if err != nil {
			return nil, ErrHeader
		}
		var record []byte
		record, buf = buf[sp+1:n-1], buf[n:]
		eq := bytes.IndexByte(record, '=')
		if eq == -1 {
			return nil, ErrHeader
		}
		key, value := record[:eq], record[eq+1:]
		keyStr := string(key)
		if keyStr == paxGNUSparseOffset || keyStr == paxGNUSparseNumBytes {
			sparseMap.Write(value)
			sparseMap.Write([]byte{','})
		} else {
			headers[keyStr] = string(value)
		}
	}
	if sparseMap.Len() != 0 {
		sparseMap.Truncate(sparseMap.Len() - 1)
		headers[paxGNUSparseMap] = sparseMap.String()
	}
	return headers, nil
}
func parsePAX ( r io . Reader ) ( map [ string ] string , error ) { buf , err := ioutil . ReadAll ( r ) if err != nil { return nil , err } var sparseMap bytes . Buffer headers := make ( map [ string ] string ) for len ( buf ) > 0 { var sp int sp = bytes . IndexByte ( buf , ' ' ) if sp == - 1 { return nil , ErrHeader } n , err := strconv . ParseInt ( string ( buf [ : sp ] ) , 10 , 0 ) if err != nil { return nil , ErrHeader } var record [ ] byte record , buf = buf [ sp + 1 : n - 1 ] , buf [ n : ] eq := bytes . IndexByte ( record , '=' ) if eq == - 1 { return nil , ErrHeader } key , value := record [ : eq ] , record [ eq + 1 : ] keyStr := string ( key ) if keyStr == paxGNUSparseOffset || keyStr == paxGNUSparseNumBytes { sparseMap . Write ( value ) sparseMap . Write ( [ ] byte { ',' } ) } else { headers [ keyStr ] = string ( value ) } } if sparseMap . Len ( ) != 0 { sparseMap . Truncate ( sparseMap . Len ( ) - 1 ) headers [ paxGNUSparseMap ] = sparseMap . String ( ) } return headers , nil }
parsePAX parses PAX headers.
parsePAX parses PAX headers .
// For GNU PAX sparse format 0.0 support. // This function transforms the sparse format 0.0 headers into sparse format 0.1 headers. // Each record is constructed as //     "%d %s=%s\n", length, keyword, value // or the header was empty to start with. // The size field ends at the first space. // Parse the first token as a decimal integer. // Extract everything between the decimal and the n -1 on the // beginning to eat the ' ', -1 on the end to skip the newline. // The first equals is guaranteed to mark the end of the key. // Everything else is value. // GNU sparse format 0.0 special key. Write to sparseMap instead of using the headers map. // Normal key. Set the value in the headers map. // Add sparse info to headers, chopping off the extra comma