func Init(dev string) (*Framebuffer, error) {
	var (
		fb  = new(Framebuffer)
		err error
	)
	fb.dev, err = os.OpenFile(dev, os.O_RDWR, os.ModeDevice)
	if err != nil {
		return nil, err
	}
	err = ioctl(fb.dev.Fd(), getFixedScreenInfo, unsafe.Pointer(&fb.finfo))
	if err != nil {
		fb.dev.Close()
		return nil, err
	}
	err = ioctl(fb.dev.Fd(), getVariableScreenInfo, unsafe.Pointer(&fb.vinfo))
	if err != nil {
		fb.dev.Close()
		return nil, err
	}
	fb.data, err = syscall.Mmap(int(fb.dev.Fd()), 0, int(fb.finfo.Smem_len+uint32(fb.finfo.Smem_start&uint64(syscall.Getpagesize()-1))), protocolRead|protocolWrite, mapShared)
	if err != nil {
		fb.dev.Close()
		return nil, err
	}
	fb.restData = make([]byte, len(fb.data))
	for i := range fb.data {
		fb.restData[i] = fb.data[i]
	}
	return fb, nil
}
Init opens framebuffer device, maps it to memory and saves its current contents.
package framebuffer
import (
	"os"
	"syscall"
	"unsafe"
)
type Framebuffer struct {
	dev      *os.File
	finfo    fixedScreenInfo
	vinfo    variableScreenInfo
	data     []byte
	restData []byte
}