-
Notifications
You must be signed in to change notification settings - Fork 11
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
Treat EDN nil as Go zero value #11
Comments
i.e. why not: v.Set(reflect.Zero(v.Type())) here: Lines 910 to 912 in 470b0ab
? |
It depends on how you need to treat As a short term solution, you can use type Good struct {
A *string
B int
} instead of type Error struct {
A string
B int
} And also get information about whether this is a So in general, I think there's value in distinguishing the between the zero value ( ;; 1
{:author #person/id 0}
;; 2
{:author nil}
;; 3
{} Typical behaviour is that the first one sets the author to the zero value, the second sets the author to null, and the third does not update the author field. I'm not against |
I agree, although (talking about unmarshalling EDN) I feel that EDN's nil (on a Clojure side) most of the time means absence of the value. i.e.
I think both may have a place. If you decide to leave the current behavior as a default one (which you are leaning to) it would help to have a mechanism to define |
[the commit above]: me trying things, i.e. no intention to change the official repo Rhetorical observation: wantptr := ttype == tokenSymbol && bytes.Equal(nilByte, bs) When unmarshalling from |
Yeah, the idea is to have type Foo struct {
Bar string `edn:",ignore-nil"
} |
some systems that I don't control could send:
which would result in:
it would make sense to convert EDN
nil
s to a Go type zero values, or simply drop them. Then we can either not worry about it or use",omitempty"
to ignore them.What do you think?
The text was updated successfully, but these errors were encountered: