Something like this is a bit simpler, avoids the need for unsafe, and
may be a little faster too:
https://play.golang.org/p/4jayHwLroR
It may be quicker to use a type switch: https://play.golang.org/p/4uu2XeVM9m
It's a pity that about the need for a dynamic type conversion on every
field, but the
Thanks Michael,
Here is the cleaner current version, thanks to your suggestion:
//writeData loops over the field vectors and write their binary
representation to an io.Writer
func (sf *File) writeData(w io.Writer) error {
if sf.NoObs == 0 {
return nil
}
if len(sf.fields) == 0
Michael,
here is the cleaner (thanks to your suggestion) current version:
//writeData loops over the field vectors and write their binary
representation to an io.Writer
func (sf *File) writeData(w io.Writer) error {
if sf.NoObs == 0 {
return nil
}
if len(sf.fields) == 0 {
you could do your unsafe cast to an appropriately-sized byte array and
write that as a single call or use it to access the bytes:
base := *(*[8]byte)(unsafe.Pointer(&doubleThing))
bs[offset+0]=base[0]
bs[offset+1]=base[1]
:
offset+=8
On Fri, Oct 27, 2017 at 10:18 PM, Tamás Gulácsi
wrote:
> Woul