Coffer
Package for copying data between memory ranges managed by C code and Go Buffers (uses cgo)
Install / Use
/learn @boggle/CofferREADME
Coffer 0.0.2
Small package for copying between a memory range managed by C code and Go Buffers.
Requires installation of github.com/boggle/gonewrong
Status: Only barely tested right now but it appears to be working :-)
Typical Usage:
import buffer import unsafe.coffer import io
var start uintptr var sz int var buf io.Buffer
coffer := coffer.NewPtrCoffer(start, sz)
// Read Bytes from C buf.ReadFrom(coffer) bytes := buf.Bytes()
// Write Bytes to C buf.WriteTo(coffer)
// or coffer.Write(buf.Bytes())
// Reset to start of memory range coffer.Seek(0, 0)
// Subsequent Read, Write, or Seek will fail // Does NOT free coffer.Close()
// Variant: Allocs using C.malloc and frees on Close() // (independent from Go's GC) coffer := coffer.NewMemCoffer(sz) Coffer.Close()
// Have fun!
