-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Will close #269 at some point #370
Conversation
Note: the |
TIL you can just change the parameters' type to |
Which parameter are you talking about? And apologies if it is obvious - my brain is a bit woolly today (evil cold virus). |
Any |
@liclac So, I'm still a bit confused about exactly what you'd like me to change. Do you mean that the parameters to the crypto functions should be all []byte instead of goja.Value? That would mean you can't pass the binary data object you get back from open() directly to the crypto functions (or any other functions that want to consume binary data), but would have to do e.g. |
ICMP echo request -> @liclac |
Oh, my response didn't send. As dop251/goja#51 points out, we should either implement an |
@liclac OK, I had some idea that it would be bad if we didn't know whether data was binary or not - that we might want other functions (like perhaps the crypto.* ones) to know this. If we just use a []byte parameter to pass it around we don't know if it is a legible string, or something that contains null bytes. But I can't really think of an example where it would give us trouble. I'll try just using byte slices everywhere and see what happens! |
@liclac OK, so here (below) is what happens when open() returns a byte slice and I read a text file and then try to print its contents on the console. I think this is what you meant with the earlier "weird edge case" comment, no? I have a file that contains:
...and open()ing it and then console.log()ing the contents will print this:
Am I understanding it correctly that you are of the opinion that we should just use []byte params anyway and break the ability to log to stdout text that was read from a file? That would mean the patch becomes very, very simple (3 lines of code changed, I think). |
The easiest solution would probably be to let the |
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.
Remember to update http.Request
to take []byte
bodies too!
@@ -47,9 +48,16 @@ func (c Console) log(ctx *context.Context, level log.Level, msgobj goja.Value, a | |||
|
|||
fields := make(log.Fields) | |||
for i, arg := range args { | |||
fields[strconv.Itoa(i)] = arg.String() | |||
if arg.ExportType() == reflect.TypeOf((*[]byte)(nil)).Elem() { |
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 can declare a global var typeBytes = reflect.TypeOf(...)
to not have to recalculate this every time.
@ragnarlonn When will you be able to fix the merge conflict and move the type calculation that @liclac commented on in console.go? I want to get this merged so we can move #420 forward. |
Closing this in favor of #524. |
A PR for you to tear to pieces, o great maintainer