wip: unmarshal

This commit is contained in:
Suyono 2023-06-18 16:28:27 +10:00
parent 1a89cd2be6
commit 33a3a90d81
6 changed files with 45 additions and 0 deletions

1
.tool-versions Normal file
View File

@ -0,0 +1 @@
golang 1.18

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module github.com/budiuno/gocsvparser
go 1.14

1
gocsvparser.go Normal file
View File

@ -0,0 +1 @@
package gocsvparser

1
marshal.go Normal file
View File

@ -0,0 +1 @@
package gocsvparser

2
proposals/initial.md Normal file
View File

@ -0,0 +1,2 @@
# Proposal 1

37
unmarshal.go Normal file
View File

@ -0,0 +1,37 @@
package gocsvparser
import (
"encoding/csv"
)
type Unmarshaler struct {
header []string
reader *csv.Reader
}
func NewUnmarshaler() *Unmarshaler {
return &Unmarshaler{}
}
func (u *Unmarshaler) WithCsvReader(reader *csv.Reader) *Unmarshaler {
u.reader = reader
return u
}
func (u *Unmarshaler) WithHeader(header []string) *Unmarshaler {
if len(header) > 0 {
newHeader := make([]string, len(header))
copy(newHeader, header)
u.header = newHeader
}
return u
}
func (u *Unmarshaler) Unmarshal(data []byte, v interface{}) error {
//TODO: implementation
return nil
}
func Unmarshal(data []byte, v interface{}) error {
return NewUnmarshaler().Unmarshal(data, v)
}