func (mq MessageQueue) Stat() (*MQInfo, error) {
	mqds := C.struct_msqid_ds{}
	rc, err := C.msgctl(C.int(mq), C.IPC_STAT, &mqds)
	if rc == -1 {
		return nil, err
	}
	mqinf := MQInfo{
		Perms: IpcPerms{
			OwnerUID:   int(mqds.msg_perm.uid),
			OwnerGID:   int(mqds.msg_perm.gid),
			CreatorUID: int(mqds.msg_perm.cuid),
			CreatorGID: int(mqds.msg_perm.cgid),
			Mode:       uint16(mqds.msg_perm.mode),
		},
		LastSend:   time.Unix(int64(mqds.msg_stime), 0),
		LastRcv:    time.Unix(int64(mqds.msg_rtime), 0),
		LastChange: time.Unix(int64(mqds.msg_ctime), 0),
		MsgCount:   uint(mqds.msg_qnum),
		MaxBytes:   uint(mqds.msg_qbytes),
		LastSender: int(mqds.msg_lspid),
		LastRcver:  int(mqds.msg_lrpid),
	}
	return &mqinf, nil
}
Stat produces information about the queue.
package sysvipc
import "C"
import (
	"time"
	"unsafe"
)
type MessageQueue int64
func GetMsgQueue(key int64, flags *MQFlags) (MessageQueue, error) {
	rc, err := C.msgget(C.key_t(key), C.int(flags.flags()))
	if rc == -1 {
		return -1, err
	}
	return MessageQueue(rc), nil
}
func (mq MessageQueue) Send(mtyp int64, body []byte, flags *MQSendFlags) error {
	b := make([]byte, len(body)+8)
	copy(b[:8], serialize(mtyp))
	copy(b[8:], body)
	rc, err := C.msgsnd(
		C.int(mq),
		unsafe.Pointer(&b[0]),
		C.size_t(len(body)),
		C.int(flags.flags()),
	)
	if rc == -1 {
		return err
	}
	return nil
}
func (mq MessageQueue) Receive(maxlen uint, msgtyp int64, flags *MQRecvFlags) ([]byte, int64, error) {
	b := make([]byte, maxlen+8)
	rc, err := C.msgrcv(
		C.int(mq),
		unsafe.Pointer(&b[0]),
		C.size_t(maxlen),
		C.long(msgtyp),
		C.int(flags.flags()),
	)
	if rc == -1 {
		return nil, 0, err
	}
	mtyp := deserialize(b[:8])
	return b[8 : rc+8], mtyp, nil
}