Skip to content
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

error when trying to encode an empty link #52

Merged
merged 3 commits into from
Nov 2, 2018
Merged

Conversation

Stebalien
Copy link
Member

Don't make nonsensical links.

@ghost ghost assigned Stebalien Nov 2, 2018
@ghost ghost added the status/in-progress In progress label Nov 2, 2018
@Stebalien Stebalien merged commit a591956 into master Nov 2, 2018
@Stebalien Stebalien deleted the fix/empty-link branch November 2, 2018 00:51
@ghost ghost removed the status/in-progress In progress label Nov 2, 2018
Copy link

@phritz phritz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I can't approve, btw)

A cid.Cid
}
type Bar struct {
A cid.Cid `refmt:",omitempty"`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semantics without omitempty are surprising. I get that omitempty skips encoding zero values. But without omitempty you can't encode a zero value? What's the intent of semantics like that and what if I really, truly want an empty value?

@Stebalien
Copy link
Member Author

Stebalien commented Nov 2, 2018

What's the intent of semantics like that and what if I really, truly want an empty value?

So, in this case, the empty value we'd want is actually "null", not an empty CID. Unfortunately, refmt doesn't support nullable structs. One can, in fact, just use A *cid.Cid to get a nullable CID but then you'd have to introduce the pointer indirection.

Really, I'd like to just add this feature to refmt. That is, I'd like to introduce a Nullable option to the atlas builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants