8 ms·
Can you explain how reflection helps here? Are you saying that people still pass tracing objects around, except they don't have to be context.Context? That's
by adrianratnapala 9y ago
Can you explain how reflection helps here? Are you saying that people still pass tracing objects around, except they don't have to be context.Context?
That's nice, but it doesn't sovle the fact that the auther (rightly!) doesn't want to add extra complication to interfaces like io.Reader
- nemothekid 9y agoReflection, the way Martini used it, was for dependency injection. So in our imaginary Go language, the io.Reader interface could be satisfied by either of two functions: Read([]byte) Read(context.Context, []byte) In a way reflection let you do operator overloading, so in your case you could just call a.Read(p) and others could a.Read(ctx, p). In Martini's case, if you wanted your handler to be cognizant of a cancellable context, you would just add the context parameter.