func (shm *SharedMemorySegment) Read(data []byte) error {
	if len(data) == 0 {
		return errors.New("allocate []byte with provided length")
	}
	for i := 0; i < len(data); i++ {
		data[i] = shm.data[i]
	}
	return nil
}
Read data segment. Attention, the segment to read will be equal to data function arg len
package windows  
import (
	"errors"
	"os"
	"reflect"
	"syscall"
	"unsafe"
)
type SharedMemorySegment struct {
	key  *uint16
	size uint
	handler *syscall.Handle
	addr    uintptr
	data    []byte
}
func CreateSharedMemory(key string, size uint) (SharedMemory, error) {
	name, err := syscall.UTF16PtrFromString(key)
	if err != nil {
		return nil, err
	}
	hMapFile, err := syscall.CreateFileMapping(syscall.InvalidHandle, nil, syscall.PAGE_READWRITE, 0, uint32(size), name)
	if err != nil {
		return nil, os.NewSyscallError("CreateFileMapping", err)
	}
	pBuf, err := syscall.MapViewOfFile(hMapFile, syscall.FILE_MAP_WRITE, 0, 0, uintptr(size))
	if err != nil {
		return nil, os.NewSyscallError("MapViewOfFile", err)
	}
	segment := &SharedMemorySegment{
		key:     name,
		size:    size,
		handler: &hMapFile,
		data:    make([]byte, int(size), int(size)),
		addr:    pBuf,
	}
	sh := (*reflect.SliceHeader)(unsafe.Pointer(&pBuf))
	sh.Len = int(size)
	sh.Cap = int(size)
	sh.Data = pBuf
	segment.data = *(*[]byte)(unsafe.Pointer(&sh))
	return segment, nil
}
func (shm *SharedMemorySegment) Write(data []byte) {
	srcLen := len(data)
	dstLen := len(shm.data)
	if srcLen > dstLen {
		panic("can't write more than source len")
	}
	shm.writeBuffer(data, shm.data)
}
func (shm *SharedMemorySegment) writeBuffer(src []byte, dst []byte) {
	copy(dst, src)
}
func (shm *SharedMemorySegment) Clear() {
	for i := 0; i < len(shm.data); i++ {
		shm.data[i] = 0
	}
}