Skip to content

Commit

Permalink
Support purego build tag
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Jan 30, 2022
1 parent 98fb47f commit be2f624
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 0 additions & 5 deletions dsvreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"unsafe"
)

// NewCSV returns new Reader that reads CSV data from r.
Expand Down Expand Up @@ -274,7 +273,3 @@ func (tr *Reader) nextCol() ([]byte, error) {
func (tr *Reader) setColError(msg string, err error) {
tr.err = fmt.Errorf("%s at row #%d, col #%d %q: %s", msg, tr.row, tr.col, tr.rowBuf, err)
}

func b2s(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
9 changes: 9 additions & 0 deletions util_nopure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build !purego

package dsvreader

import "unsafe"

func b2s(b []byte) string {
return *(*string)(unsafe.Pointer(&b))
}
7 changes: 7 additions & 0 deletions util_pure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build purego

package dsvreader

func b2s(b []byte) string {
return string(b)
}

0 comments on commit be2f624

Please sign in to comment.