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

Enable fields to be marked for omission from a struct #198

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bifurcation
Copy link
Owner

This way you can have structs that marshal / unmarshal as TLS, but also have extra information that is produced locally. The proposed syntax is:

type Foo struct {
  A uint16
  B uint16 `tls:"omit"`
  C uint16
}

@bifurcation bifurcation requested a review from ekr September 2, 2018 13:06
@ekr
Copy link
Collaborator

ekr commented Sep 2, 2018

Why not just use lower-case for this? Those fields are inaccessible to reflection anyway.

For instance: https://github.com/ekr/minq/blob/master/codec.go#L155

@bifurcation
Copy link
Owner Author

Renewing this PR. @ekr - you could use private fields for this, but I don't see a need to conflate the two ideas. encoding/json, for example, makes exactly this distinction, allowing a "-" annotation for a public field you want to omit in the JSON encoding.

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.

2 participants