Skip to content

Commit

Permalink
fixed incompatibility with go1.19 introduced with csv producer
Browse files Browse the repository at this point in the history
Now the producer uses a go1.19 idiom for reflect.

* fixes #287

Signed-off-by: Frederic BIDON <[email protected]>
  • Loading branch information
fredbi committed Jan 25, 2024
1 parent 13c451f commit 50a16d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go_version: ['oldstable', 'stable' ]
go_version: ['oldstable', 'stable', '1.19' ]

steps:
- name: Run unit tests
Expand Down
14 changes: 10 additions & 4 deletions csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,16 @@ func CSVConsumer(opts ...CSVOpt) Consumer {
if err := pipeCSV(csvWriter, csvReader, o); err != nil {
return err
}
v.Grow(len(csvWriter.records))
v.SetCap(len(csvWriter.records)) // in case Grow was unnessary, trim down the capacity
v.SetLen(len(csvWriter.records))
reflect.Copy(v, reflect.ValueOf(csvWriter.records))

/*
// with go1.20:
v.Grow(len(csvWriter.records))
v.SetCap(len(csvWriter.records)) // in case Grow was unnessary, trim down the capacity
v.SetLen(len(csvWriter.records))
reflect.Copy(v, reflect.ValueOf(csvWriter.records))
*/
v.SetLen(0)
v.Set(reflect.AppendSlice(v, reflect.ValueOf(csvWriter.records)))

return nil

Expand Down

0 comments on commit 50a16d3

Please sign in to comment.