27 lines
493 B
Go
27 lines
493 B
Go
package change
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"io"
|
|
|
|
"git.crumpington.com/public/jldb/lib/errs"
|
|
)
|
|
|
|
func writeBin(w io.Writer, data ...any) error {
|
|
for _, value := range data {
|
|
if err := binary.Write(w, binary.LittleEndian, value); err != nil {
|
|
return errs.IO.WithErr(err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func readBin(r io.Reader, ptrs ...any) error {
|
|
for _, ptr := range ptrs {
|
|
if err := binary.Read(r, binary.LittleEndian, ptr); err != nil {
|
|
return errs.IO.WithErr(err)
|
|
}
|
|
}
|
|
return nil
|
|
}
|