I am trying to achieve below functionality and planning to implement my new type as a ReadWriter interface for extensibility and ease of testing.
- Reader :- Reader is expected to use http package and call web API that will return response in JSON format. I am planning to implementing this as a reader interface. While doing this I have some doubts :-
A. Is it correct to implement above functionality as a reader interface ?
B. We need to send byte slice that is allocated but what should be the size of this slice? How to decide it? - Writer :- Writer is expected to unmarshal byte slice to a user defined type. While doing this I have some doubts :-
A. Is it correct to implement above functionality as a writer interface ?
B. As writer interface needs to return number of bytes written, how can I found how many bytes are unmarshalled ?