func findPostamble(b []byte) *packContentPostamble {
	if len(b) == 0 {
		// no postamble
		return nil
	}

	// length of postamble is the last byte
	postambleLength := int(b[len(b)-1])
	if postambleLength < 5 { // nolint:gomnd
		// too short, must be at least 5 bytes (checksum + own length)
		return nil
	}

	postambleStart := len(b) - 1 - postambleLength
	postambleEnd := len(b) - 1

	if postambleStart < 0 {
		// invalid last byte
		return nil
	}

	postambleBytes := b[postambleStart:postambleEnd]
	payload, checksumBytes := postambleBytes[0:len(postambleBytes)-4], postambleBytes[len(postambleBytes)-4:]
	checksum := binary.BigEndian.Uint32(checksumBytes)
	validChecksum := crc32.ChecksumIEEE(payload)

	if checksum != validChecksum {
		// invalid checksum, not a valid postamble
		return nil
	}

	return decodePostamble(payload)
}
// findPostamble detects if a given content of bytes contains a possibly valid postamble, and returns it if so
// NOTE, even if this function returns a postamble, it should not be trusted to be correct, since it's not
// cryptographically signed. this is to facilitate data recovery.
findPostamble detects if a given content of bytes contains a possibly valid postamble, and returns it if so
NOTE, even if this function returns a postamble, it should not be trusted to be correct, since it's not
cryptographically signed. this is to facilitate data recovery.
// findPostamble detects if a given content of bytes contains a possibly valid postamble and returns it if so // NOTE even if this function returns a postamble it should not be trusted to be correct since it ' s not // cryptographically signed . this is to facilitate data recovery .
func findPostamble(b []byte) *packContentPostamble {
	if len(b) == 0 {
		return nil
	}
	postambleLength := int(b[len(b)-1])
	if postambleLength < 5 { 
		return nil
	}
	postambleStart := len(b) - 1 - postambleLength
	postambleEnd := len(b) - 1
	if postambleStart < 0 {
		return nil
	}
	postambleBytes := b[postambleStart:postambleEnd]
	payload, checksumBytes := postambleBytes[0:len(postambleBytes)-4], postambleBytes[len(postambleBytes)-4:]
	checksum := binary.BigEndian.Uint32(checksumBytes)
	validChecksum := crc32.ChecksumIEEE(payload)
	if checksum != validChecksum {
		return nil
	}
	return decodePostamble(payload)
}
func findPostamble ( b [ ] byte ) * packContentPostamble { if len ( b ) == 0 { return nil } postambleLength := int ( b [ len ( b ) - 1 ] ) if postambleLength < 5 { return nil } postambleStart := len ( b ) - 1 - postambleLength postambleEnd := len ( b ) - 1 if postambleStart < 0 { return nil } postambleBytes := b [ postambleStart : postambleEnd ] payload , checksumBytes := postambleBytes [ 0 : len ( postambleBytes ) - 4 ] , postambleBytes [ len ( postambleBytes ) - 4 : ] checksum := binary . BigEndian . Uint32 ( checksumBytes ) validChecksum := crc32 . ChecksumIEEE ( payload ) if checksum != validChecksum { return nil } return decodePostamble ( payload ) }
findPostamble detects if a given content of bytes contains a possibly valid postamble, and returns it if so
NOTE, even if this function returns a postamble, it should not be trusted to be correct, since it's not
cryptographically signed.
findPostamble detects if a given content of bytes contains a possibly valid postamble and returns it if so NOTE even if this function returns a postamble it should not be trusted to be correct since it ' s not cryptographically signed .
// no postamble // length of postamble is the last byte // nolint:gomnd // too short, must be at least 5 bytes (checksum + own length) // invalid last byte // invalid checksum, not a valid postamble