Ingo Oeser | a4e3bbb | 2016-08-16 17:57:15 +0200 | [diff] [blame] | 1 | # Well Known Struct Tags |
| 2 | ## Background |
| 3 | |
| 4 | Go offers [struct tags](https://golang.org/ref/spec#Tag) which are discoverable via reflection. These enjoy a wide range of use in the standard library in the JSON/XML and other encoding packages. The community welcomed them and build ORMs, further encodings, flag parsers and much more around them. |
| 5 | |
| 6 | Since esp. while handling encodings and ORMs single sourcing data structures is beneficial for data structures. |
| 7 | |
| 8 | ## Problem description |
| 9 | Due to increased usage of Go and thus Go [struct tags](https://golang.org/ref/spec#Tag), clashes become inevitable. |
| 10 | |
| 11 | ## Solution |
| 12 | The list below is a best effort to document well known struct tags used by packages which available to the public. |
| 13 | |
| 14 | ## Format of the list |
| 15 | * Struct tag as extracted by calling https://godoc.org/reflect#StructTag.Get with this tag as the `key` argument. |
| 16 | * Documentation link of this package using https://godoc.org |
| 17 | |
| 18 | ### Example entry |
| 19 | Tag | Documentation |
| 20 | ----|----- |
| 21 | xml | https://godoc.org/encoding/xml |
| 22 | |
| 23 | ### Change Management |
| 24 | List entries can be added by anyone who creates a public package where a new tag is used. |
| 25 | List entries can be removed when the links to the package documentation stops working or the author(s) of that package requests it. |
| 26 | |
| 27 | ## List of Well Known Struct Tags |
| 28 | Tag | Documentation |
| 29 | ----|----- |
| 30 | xml | https://godoc.org/encoding/xml |
| 31 | json | https://godoc.org/encoding/json |
| 32 | asn1 | https://godoc.org/encoding/asn1 |