You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: snappy.go
    path of file: ./repos/cockroach/pkg/rpc
    
    the code of the file until where you have to start completion: // Copyright 2017 The Cockroach Authors.
//
// Use of this software is govern
    
func readDecompressedLength(p []byte) (int, bool) {
	for {
		if len(p) < 4 {
			// Corrupt chunk.
			return 0, false
		}
		chunkType := p[0]
		chunkLen := int(p[1]) | int(p[2])<<8 | int(p[3])<<16
		p = p[4:] // strip chunk header
		if chunkType != chunkTypeDecompressedLength {
			if chunkLen > len(p) {
				// Corrupt chunk.
				return 0, false
			}
			// Jump to next chunk.
			p = p[chunkLen:]
			continue
		}
		// Decode the decompressed length chunk.
		v, n := binary.Uvarint(p)
		if n <= 0 {
			// Uvarint decoding failed.
			return 0, false
		}
		if n != chunkLen {
			// Corrupt decompressed length chunk. We don't strictly need
			// to detect this case, but it acts as a useful sanity check.
			return 0, false
		}
		return int(v), true
	}
}