You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
== Problem ==
Tags may be used by multiple packages, and there's no convention today
to enable them to namespace their use so that they can obtain the
information they need while still allowing the struct tag to be used
by other packages.
This means a struct may have to be declared twice with exactly the
same fields, but with differing tags, to satisfy the needs of
different packages.
== Suggested solution ==
Establish a loose convention so that tags can optionally include
namespaces in the form NS(value) separated by spaces. In the absence
of any namespaces (no '(' in the tag string), the whole tag value
continues to be taken into account.
As an example, the json package would be enhanced so that the
marshalling of JSON values specifically would make this:
type T struct { F int "BEFORE KEY(name) AFTER" }
is equivalent to this:
type T struct { F int "name" }
and this:
type T struct { F int "OTHER(name)" }
is equivalent to this:
type T struct { F int "" }
== Optional reflect enhancement ==
Optionally, the reflect package could receive a new function:
func ParseTag(ns, tag string) string
This would handle the semantics defined above.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: