johnl | 7b3f126 | 2017-01-28 21:00:38 +0100 | [diff] [blame] | 1 | # Well-known struct tags |
Ingo Oeser | a4e3bbb | 2016-08-16 17:57:15 +0200 | [diff] [blame] | 2 | ## Background |
| 3 | |
johnl | 7b3f126 | 2017-01-28 21:00:38 +0100 | [diff] [blame] | 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. |
Ingo Oeser | a4e3bbb | 2016-08-16 17:57:15 +0200 | [diff] [blame] | 5 | |
johnl | 7b3f126 | 2017-01-28 21:00:38 +0100 | [diff] [blame] | 6 | The community welcomed them and has built ORMs, further encodings, flag parsers and much more around them since, especially for these tasks, single-sourcing is beneficial for data structures. |
Ingo Oeser | a4e3bbb | 2016-08-16 17:57:15 +0200 | [diff] [blame] | 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 |
johnl | 7b3f126 | 2017-01-28 21:00:38 +0100 | [diff] [blame] | 12 | The list below is a best effort to document well-known struct tags used by packages which are available to the public. |
Ingo Oeser | a4e3bbb | 2016-08-16 17:57:15 +0200 | [diff] [blame] | 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 | |
johnl | 7b3f126 | 2017-01-28 21:00:38 +0100 | [diff] [blame] | 27 | ## List of well-known struct tags |
Addison Luh | 60f0f98 | 2017-02-19 15:13:43 -0800 | [diff] [blame] | 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 |
| 33 | reform | https://godoc.org/gopkg.in/reform.v1 |
Addison Luh | d5e1607 | 2017-02-19 15:20:14 -0800 | [diff] [blame] | 34 | bigquery | https://godoc.org/cloud.google.com/go/bigquery |
Addison Luh | 60f0f98 | 2017-02-19 15:13:43 -0800 | [diff] [blame] | 35 | datastore | https://godoc.org/cloud.google.com/go/datastore |
Addison Luh | d5e1607 | 2017-02-19 15:20:14 -0800 | [diff] [blame] | 36 | spanner | https://godoc.org/cloud.google.com/go/spanner |
Logan Lembke | 89fa623 | 2017-06-12 14:00:33 -0600 | [diff] [blame] | 37 | bson | https://godoc.org/labix.org/v2/mgo/bson |
Samuel Volin | 999b14f | 2018-06-29 09:05:49 -0600 | [diff] [blame] | 38 | gorm | https://godoc.org/github.com/jinzhu/gorm |
Steve Moyer | c2311da | 2019-01-23 08:34:57 -0500 | [diff] [blame] | 39 | yaml | https://godoc.org/gopkg.in/yaml.v2 |
| 40 | validate | https://github.com/go-playground/validator |