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

Should MarshalChan take an interface{} instead of a chan interface{} #112

Open
alex opened this issue Apr 25, 2019 · 1 comment
Open

Should MarshalChan take an interface{} instead of a chan interface{} #112

alex opened this issue Apr 25, 2019 · 1 comment

Comments

@alex
Copy link
Contributor

alex commented Apr 25, 2019

Right now MarshalChan takes a chan interface{}. However this means that if you have a typed-chan you need to copy all the elements to a new in order to pass them to this function.

If MarshalChan took an interface{} (the way UnmarshalToChan does), then we could avoid this problem.

@kishaningithub
Copy link

kishaningithub commented Aug 21, 2020

@alex Instead of converting between channel types i find it very simple and idiomatic to do this

csvWriter := make(chan interface{}, 1000)
go func() {
    _ = gocsv.MarshalChan(csvWriter, gocsv.DefaultCSVWriter(out))
}()   
// several bussiness logic
csvWriter <-  CsvStruct{name: "name", age: 90}

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

No branches or pull requests

2 participants