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: sock.go
    path of file: ./repos/sliver/implant/vendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1
    
    the code of the file until where you have to start completion: package wasi_snapshot_preview1

import (
	"context"
	"syscall"

	"github.com/tetratelabs/wazero/api"
	socketapi "github.com/tetratelabs/wazero/internal/sock"
	"github.com/tetratelabs/wazero/internal/sysfs"
	"github.com/tetratelabs/wazero/internal/wasip1"
	"github.com/tetratelabs/wazero/internal/wasm"
)

// sockAccept is the WASI function named SockAcceptName which accepts a new
// incoming connection.
//
// See: https://github.com/WebAssem
    
func sockRecvFn(_ context.Context, mod api.Module, params []uint64) syscall.Errno {
	mem := mod.Memory()
	fsc := mod.(*wasm.ModuleInstance).Sys.FS()

	fd := int32(params[0])
	riData := uint32(params[1])
	riDataCount := uint32(params[2])
	riFlags := uint8(params[3])
	resultRoDatalen := uint32(params[4])
	resultRoFlags := uint32(params[5])

	var conn socketapi.TCPConn
	if e, ok := fsc.LookupFile(fd); !ok {
		return syscall.EBADF // Not open
	} else if conn, ok = e.File.(socketapi.TCPConn); !ok {
		return syscall.EBADF // Not a conn
	}

	if riFlags & ^(wasip1.RI_RECV_PEEK|wasip1.RI_RECV_WAITALL) != 0 {
		return syscall.ENOTSUP
	}

	if riFlags&wasip1.RI_RECV_PEEK != 0 {
		// Each record in riData is of the form:
		// type iovec struct { buf *uint8; bufLen uint32 }
		// This means that the first `uint32` is a `buf *uint8`.
		firstIovecBufAddr, ok := mem.ReadUint32Le(riData)
		if !ok {
			return syscall.EINVAL
		}
		// Read bufLen
		firstIovecBufLen, ok := mem.ReadUint32Le(riData + 4)
		if !ok {
			return syscall.EINVAL
		}
		firstIovecBuf, ok := mem.Read(firstIovecBufAddr, firstIovecBufLen)
		if !ok {
			return syscall.EINVAL
		}
		n, err := conn.Recvfrom(firstIovecBuf, sysfs.MSG_PEEK)
		if err != 0 {
			return err
		}
		mem.WriteUint32Le(resultRoDatalen, uint32(n))
		mem.WriteUint16Le(resultRoFlags, 0)
		return 0
	}

	// If riFlags&wasip1.RECV_WAITALL != 0 then we should
	// do a blocking operation until all data has been retrieved;
	// otherwise we are able to return earlier.
	// For simplicity, we currently wait all regardless the flag.
	bufSize, errno := readv(mem, riData, riDataCount, conn.Read)
	if errno != 0 {
		return errno
	}
	mem.WriteUint32Le(resultRoDatalen, bufSize)
	mem.WriteUint16Le(resultRoFlags, 0)
	return 0
}