mint icon indicating copy to clipboard operation
mint copied to clipboard

Enable fields to be marked for omission from a struct

Open bifurcation opened this issue 6 years ago • 2 comments

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 avatar Sep 02 '18 13:09 bifurcation

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

ekr avatar Sep 02 '18 15:09 ekr

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.

bifurcation avatar Sep 01 '19 18:09 bifurcation