zserge / lorca

Build cross-platform modern desktop apps in Go + HTML5
MIT License
8.04k stars 535 forks source link

feat: added RawValue interface #127

Closed nrwiersma closed 3 years ago

nrwiersma commented 4 years ago

To allow for the detection of a nil return, a new interface is added (to maintain backwards compatibility) and implemented by value. This interface, RawValue, allows the retrieval of the raw bytes but requires a type assertion.

Fixes #126

timcolson commented 3 years ago

I appreciate the PR, @nrwiersma. I assume it's an improvement, but as a NewB to Lorca, I'm curious about the reason for it. What happens currently when a nil is returned? (from JS, yes?) Thx!

nrwiersma commented 3 years ago

@timcolson If you call To(interface{}) when it is nil you get some fairly nasty errors.

timcolson commented 3 years ago

Thx @nrwiersma, I appreciate the context. Surface of change seems minimal, so curious to see if @zserge will merge it in. 👍

zserge commented 3 years ago

I have no objections against the Bytes() method. But I think that adding it to the existing Value interface would still be backwards-compatible (adding methods should be fine, unlike removing/renaming them). I double anyone implements this interface outside of Lorca. And it should simplify the calling code.

timcolson commented 3 years ago

Yay! Another merge. Woot! 👍