Code Monkey home page Code Monkey logo

Comments (6)

timblackwell avatar timblackwell commented on August 26, 2024 1

Closing the reader does produce an error and stop the marshalling process. My problem was with my surrounding code, forgetting to close the channel. Only if the marshalling completes successfully is the channel closed.

from gocsv.

pikanezi avatar pikanezi commented on August 26, 2024

Are you using https://godoc.org/github.com/gocarina/gocsv#UnmarshalToChan ?

from gocsv.

timblackwell avatar timblackwell commented on August 26, 2024

Yes I am using this method.
I have a few downstream consumers that need the input channel to be closed
before they can exit.
On 2 Mar 2016 3:59 p.m., "Vincent Nรซel" [email protected] wrote:

Are you using https://godoc.org/github.com/gocarina/gocsv#UnmarshalToChan
?

โ€”
Reply to this email directly or view it on GitHub
#24 (comment).

from gocsv.

pikanezi avatar pikanezi commented on August 26, 2024

I don't see any clean way to do that. You could close the channel, but it would panic because you can't send values to a closed channel.

I don't know of any easy method to check if a channel is closed without trying to read from it.

If you have an idea to how we could do that without changing the API, i would be happy to hear it. If not, the only solution would be to write another function which take two channels, one which will be the output of the csv read and the other one to cancel the unmarshalling.

from gocsv.

timblackwell avatar timblackwell commented on August 26, 2024

Is there any way to detect that the reader is close and nothing left to read?
If not then I would agree adding a cancelation channel would be to natural route forward.

Would you accept a pull request adding this functionality using this approach?

from gocsv.

pikanezi avatar pikanezi commented on August 26, 2024

Yes of course :) I will look into why does closing the reader does not stop the reading, looks suspicious to me.

from gocsv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.