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

Moves cli helpers to pkgs #31

Merged
merged 8 commits into from
Dec 16, 2016
Merged

Conversation

davemt
Copy link
Contributor

@davemt davemt commented Nov 30, 2016

Moves the CLI helper functions to packages so that they are made available as part of the API.

It also switches some of the Read functions to be io.ReadFull to ensure full reads as per recommendation in #18.

Resolves #30.

"github.com/Comcast/gots"
)

// Sync finds the offset of the next packet sync byte and returns the offset of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should start with FindNextSync.

Also, I think that there is a bug here. I know that you didn't introduce it, but it should be fixed. If we are checking the next packet's sync byte after we find the first sync byte, the reader is left skipping the first valid packet. I would argue that this func should only consume those bytes before the first sync byte. A reader is tricky because once we find a sync byte, we have consumed it. I am not sure the best way to solve this, but I would consider using a []byte].

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking #18 We could likely solve this with bufio.Reader

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I noticed this and actually that is one reason I changed the name (I missed the comment). In the parsefile example it does the seek to the position returned so the change of the reader position caused here doesn't affect it, but it would be better to have this actually bring the reader to the right point instead.

Out of curiosity, do you know the reason it also checks the 2nd sync after the first found?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the next sync byte is checked. It could be just to make sure it's actually a packet start and not an arbitrary 0x47. Any additional sync byte verification should be done explicitly by the user of the library though.

return pat, nil
}
}
return nil, gots.ErrPATNotFound
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line not needed

@guygrigsby
Copy link
Collaborator

guygrigsby commented Dec 5, 2016

LGTM. Once you send me the signed CLA the changes can be merged. [email protected]

@guygrigsby
Copy link
Collaborator

@davemt Are you going to sign the CLA or should I close this?

@davemt
Copy link
Contributor Author

davemt commented Dec 15, 2016

Ah, your previous comment slipped by me. I'll send it over to you.

@guygrigsby guygrigsby merged commit 20a9c32 into Comcast:master Dec 16, 2016
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

Successfully merging this pull request may close these issues.

2 participants