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

Add LineBufferSize option field #85

Merged
merged 2 commits into from
Mar 27, 2022

Conversation

Crevil
Copy link
Contributor

@Crevil Crevil commented Mar 8, 2022

To support configuring the line buffer size a new field LineBufferSize is added
to the cmd.Options struct. This allows configuring the line buffer size to the
callers needs instead of relying on the DEFAULT_LINE_BUFFER_SIZE.

This fixes #66 .

To support configuring the line buffer size a new field LineBufferSize is added
to the cmd.Options struct. This allows configuring the line buffer size to the
callers needs instead of relying on the DEFAULT_LINE_BUFFER_SIZE.
cmd.go Outdated
// value DEFAULT_LINE_BUFFER_SIZE is usually sufficient, but if
// ErrLineBufferOverflow errors occur, try increasing the size with this
// field.
LineBufferSize int
Copy link
Member

Choose a reason for hiding this comment

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

Let's make it unit because it can't be negative (or zero). Then below, if options.LineBufferSize > 0 {.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm unsure what you mean. uint instead or change the name of the field? 🙏

Copy link
Member

Choose a reason for hiding this comment

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

Use type uint instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the PR now. It does bring a, maybe only theoretical, implication. As OutputStream.SetLineBufferSize accept an int we need to cast it. Tihs could potentially bring an integer overflow as the range of uint is larger than int due to its unsigned nature. 🤔 WDYT, acceptable risk? Should we add a check?

@daniel-nichter
Copy link
Member

Looks good.

Re unit to int overflow: I think it's an acceptable risk because a buff size in the billions range will probably crash/run out of memory before the actual overflow becomes an issue.

@daniel-nichter daniel-nichter merged commit 525de6b into go-cmd:master Mar 27, 2022
@daniel-nichter
Copy link
Member

Released as v1.4.1.

@Crevil
Copy link
Contributor Author

Crevil commented Mar 27, 2022

Thank you for your time in supporting this project 🙌🎉

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.

how to change the bufSize of the stdoutStream when i use cmd.NewCmdOptions.. to get the object?
2 participants