Comments (7)
Good observation.
The basic structure of safeString
was modeled on how the standard library fmt
package handles panics. It's been a while since I implemented it here, and I haven't tracked if the fmt
package's handling of panics has improved or changed since I looked at it back then, but here is the pertinent code in fmt
today: https://golang.org/src/fmt/print.go#L530. At first glance it looks like fmt
tries harder to avoid propagating the panic.
I tend to agree with your suggestion that we can and probably should do more here. Would you like to work on a PR to improve this?
from logfmt.
I took a look at fmt/print.go
; it will take first the %v
format string; if that panics and it was a null pointer then <nil>
; otherwise try to print the panic value; if that panics then it re-throws the panic.
I can get similar behaviour by writing s, ok = fmt.Sprintf("PANIC:%v", panicVal), false
in the else clause of safeString
. Will try to do a PR with this today.
To what extent do you want the decode side to work with panic values? Perhaps they should obviously fail to decode?
from logfmt.
That sounds like a reasonable approach to me. If you do submit a PR please make the same improvements to safeError
and safeMarshal
as well.
I don't think the decode side needs to do anything special. The decoder only returns []byte
data for the keys and values it parses. It doesn't interpret the keys or values in any way and I don't think it should start now.
from logfmt.
I submitted a PR.
from logfmt.
Yes, you did, and I totally lost track of that. My apologies.
I'll try to review that soon. I've also been thinking about another change to improve the way this package handles invalid keys. So I'd like to work on that and probably release it together with your improvements in v0.4.0.
from logfmt.
Was it done? Can this issue be closed?
from logfmt.
Yes, it was done. #7 was merged. Don't know why the issue didn't get closed. Thanks for the reminder.
from logfmt.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from logfmt.