-
Notifications
You must be signed in to change notification settings - Fork 581
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
fix: Parse prompt input JSON using object or array chars #538
Conversation
Codecov Report
@@ Coverage Diff @@
## main #538 +/- ##
==========================================
+ Coverage 62.65% 63.08% +0.43%
==========================================
Files 194 194
Lines 10827 10837 +10
Branches 85 85
==========================================
+ Hits 6784 6837 +53
+ Misses 3302 3269 -33
+ Partials 741 731 -10
Continue to review full report at Codecov.
|
944864f
to
f25af04
Compare
Fixes #492. There is no more single-quote parsing, and instead we use a JSON decoder for multiline values. This is a much better UX!
f25af04
to
60ad570
Compare
pipeReader, pipeWriter := io.Pipe() | ||
defer pipeWriter.Close() | ||
defer pipeReader.Close() | ||
go func() { | ||
_, _ = pipeWriter.Write([]byte(line)) | ||
_, _ = reader.WriteTo(pipeWriter) | ||
}() |
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.
I'm a bit confused about the purpose of the pipe here. Couldn't you just create a new bytes.Buffer
from line
and call reader.WriteTo(newBuf)
?
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.
https://pkg.go.dev/bufio#Reader.Peek would work well here too
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.
Nah, bytes.Buffer
will EOF if read, which we don't want. I had that initially too!
I was going to change the reader to peek, but it's an unknown amount of bytes until a newline, so it felt a bit off!
Going to merge, but if the above doesn't make sense just LMK!
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.
Interesting. Makes sense to me!
Fixes #492. There is no more single-quote parsing, and instead we use a JSON decoder for multiline values. This is a much better UX!