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: base.go
    path of file: ./repos/cockroach/pkg/ccl/sqlproxyccl/interceptor
    
    the code of the file until where you have to start completion: // Copyright 2022 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a c
    
func (p *pgInterceptor) ReadMsg() (msg []byte, err error) {
	// Peek header of the current message for message size.
	_, size, err := p.PeekMsg()
	if err != nil {
		return nil, err
	}

	// Can the entire message fit into the buffer?
	if size <= len(p.buf) {
		if err := p.ensureNextNBytes(size); err != nil {
			// Possibly due to a timeout or context cancellation.
			return nil, err
		}

		// Return a slice to the internal buffer to avoid an allocation here.
		retBuf := p.buf[p.readPos : p.readPos+size]
		p.readPos += size
		return retBuf, nil
	}

	// Message cannot fit, so we will have to allocate.
	msg = make([]byte, size)

	// Copy bytes which have already been read.
	n := copy(msg, p.buf[p.readPos:p.writePos])
	p.readPos += n

	// Read more bytes.
	if _, err := io.ReadFull(p.src, msg[n:]); err != nil {
		return nil, err
	}

	return msg, nil
}