feat: more capable csv consumer and producer#280
Merged
fredbi merged 1 commit intogo-openapi:masterfrom Dec 22, 2023
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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>
youyuanwu
approved these changes
Dec 22, 2023
Member
Author
|
Thanks @youyuanwu i know this one was demanding for review… |
Member
|
@fredbi No problem. Thanks for making these improvements. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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