-
Notifications
You must be signed in to change notification settings - Fork 534
Conversation
The old pktline API only had one method: New, that receives the payloads and return the new PktLine, that was an io.Reader. This means you have to prepare the contents beforehand, in a [][]byte and then call the ctor to build the pktlines. Now, the construction of the pktlines and the method to add payloads are separated: New() // creates an empty PktLines AddFlush() Add(pp ...[]byte) AddString(pp ...string) and a PktLines has a public member R, which is the io.Reader of the pktlines added.
IMHO the structure can be Packfiles, but the name of the package should be the name of the format. |
Agree @mcuadros, will do that. |
I will also change the public attribute to a Reader method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a little suggestion
// New returns an empty PktLines (with no payloads) ready to be used. | ||
func New() *PktLines { | ||
return &PktLines{ | ||
R: io.MultiReader([]io.Reader{}...), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe better if it would be something like p.Reader()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, will do!
Package name changed to R attribute removed, now PktLines are Readers themselves. PTAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Change pktline API so you can add payloads The old pktline API only had one method: New, that receives the payloads and return the new PktLine, that was an io.Reader. This means you have to prepare the contents beforehand, in a [][]byte and then call the ctor to build the pktlines. Now, the construction of the pktlines and the method to add payloads are separated: New() // creates an empty PktLines AddFlush() Add(pp ...[]byte) AddString(pp ...string) and a PktLines has a public member R, which is the io.Reader of the pktlines added. * metalinter * change package name from pktlines to pktline * change package name from pktlines to pktline for true * make pktlines a reader instead of have a reader
The old pktline API only had one method: New, that receives the
payloads and return the new PktLine, that was an io.Reader. This means
you have to prepare the contents beforehand, in a [][]byte or a []string and then
call the ctor to build the pktlines:
Now, the construction of the pktlines and the methods to add payloads and flush-pkts are
separated and the reader is an attribute:
I have also change the name of the package to its plural version: pktlines, as the package purpose is to handle several pktlines together, not just one.