Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: more capable csv consumer and producer #280

Merged
merged 1 commit into from
Dec 22, 2023

Conversation

fredbi
Copy link
Member

@fredbi fredbi commented Dec 13, 2023

This PR allows to use the CSV consumer and producer in a more versatile way. There is no breaking change to the interface.

  • fixes CSVProducer returns error 'data type must be byte array' #263 (types built with an io.Reader should be able to produce CSV)

  • csv/consumer can now consume CSV into *csv.Writer, io.Writer, io.ReaderFrom, encoding.BinaryUnmarshaler

  • also supports the new CSVWriter interface, i.e. anything that can Write([]string) error like *csv.Writer

  • also supports pointers with underlying type *[][]string, *[]byte and *string, not just *[]byte

  • csv/producer can now produce CSV from *csv.Reader, io.Reader, io.WriterTo, encoding.BinaryMarshaler

  • also supports the new CSVReader interface, i.e. anything that can Read() ([]string, error) like *csv.Reader

  • also supports underlying types [][]string, []byte and string, not just []byte

  • CSVConsumer and CSVProducer now stream CSV records whenever possible,

  • like ByteStreamConsumer and Producer, added the CSVCloseStream() option

  • added support to (optionally) configure the CSV format with CSVOpts, using the options made available by the standard library

  • doc: documented the above in the exported func signatures

  • test: added full unit test of the CSVConsumer and Producer

Copy link

codecov bot commented Dec 13, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (442694d) 82.27% compared to head (2825ebb) 83.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #280      +/-   ##
==========================================
+ Coverage   82.27%   83.75%   +1.47%     
==========================================
  Files          45       46       +1     
  Lines        3447     3687     +240     
==========================================
+ Hits         2836     3088     +252     
+ Misses        499      491       -8     
+ Partials      112      108       -4     
Flag Coverage Δ
oldstable 83.75% <100.00%> (+1.47%) ⬆️
stable 83.75% <100.00%> (+1.47%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This PR allows to use the CSV consumer and producer in a more versatile way.
There is no breaking change to the interface.

* fixes go-openapi#263 (types built with an io.Reader should be able to produce
  CSV)

* csv/consumer can now consume CSV into *csv.Writer, io.Writer, io.ReaderFrom,
  encoding.BinaryUnmarshaler
* also supports the new CSVWriter interface, i.e. anything that can
  Write([]string) error like *csv.Writer
* also supports pointers with underlying type *[][]string, *[]byte and *string, not just
  *[]byte

* csv/producer can now produce CSV from *csv.Reader, io.Reader,
  io.WriterTo, encoding.BinaryMarshaler
* also supports the new CSVReader interface, i.e. anything that can
  Read() ([]string, error) like *csv.Reader
* also supports underlying types [][]string, []byte and string, not just
  []byte

* CSVConsumer and CSVProducer now stream CSV records whenever possible,
* like ByteStreamConsumer and Producer, added the CSVCloseStream()
  option

* added support to (optionally) configure the CSV format with CSVOpts,
  using the options made available by the standard library

* doc: documented the above in the exported func signatures
* test: added full unit test of the CSVConsumer and Producer

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi
Copy link
Member Author

fredbi commented Dec 22, 2023

Thanks @youyuanwu i know this one was demanding for review…

@fredbi fredbi merged commit cc8632e into go-openapi:master Dec 22, 2023
10 checks passed
@youyuanwu
Copy link
Member

@fredbi No problem. Thanks for making these improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSVProducer returns error 'data type must be byte array'
2 participants