blob: fa3db8cb1d2666d4fafee729c683e8409c6a0115 [file] [log] [blame] [view]
johnl7b3f1262017-01-28 21:00:38 +01001# Well-known struct tags
Ingo Oesera4e3bbb2016-08-16 17:57:15 +02002## Background
3
johnl7b3f1262017-01-28 21:00:38 +01004Go 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 Oesera4e3bbb2016-08-16 17:57:15 +02005
johnl7b3f1262017-01-28 21:00:38 +01006The 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 Oesera4e3bbb2016-08-16 17:57:15 +02007
8## Problem description
9Due to increased usage of Go and thus Go [struct tags](https://golang.org/ref/spec#Tag), clashes become inevitable.
10
11## Solution
johnl7b3f1262017-01-28 21:00:38 +010012The list below is a best effort to document well-known struct tags used by packages which are available to the public.
Ingo Oesera4e3bbb2016-08-16 17:57:15 +020013
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
19Tag | Documentation
20----|-----
21xml | https://godoc.org/encoding/xml
22
23### Change Management
24List entries can be added by anyone who creates a public package where a new tag is used.
25List entries can be removed when the links to the package documentation stops working or the author(s) of that package requests it.
26
johnl7b3f1262017-01-28 21:00:38 +010027## List of well-known struct tags
Addison Luh60f0f982017-02-19 15:13:43 -080028Tag | Documentation
29----------|---------------
30xml | https://godoc.org/encoding/xml
31json | https://godoc.org/encoding/json
32asn1 | https://godoc.org/encoding/asn1
33reform | https://godoc.org/gopkg.in/reform.v1
Addison Luhd5e16072017-02-19 15:20:14 -080034bigquery | https://godoc.org/cloud.google.com/go/bigquery
Addison Luh60f0f982017-02-19 15:13:43 -080035datastore | https://godoc.org/cloud.google.com/go/datastore
Addison Luhd5e16072017-02-19 15:20:14 -080036spanner | https://godoc.org/cloud.google.com/go/spanner
Logan Lembke89fa6232017-06-12 14:00:33 -060037bson | https://godoc.org/labix.org/v2/mgo/bson
Samuel Volin999b14f2018-06-29 09:05:49 -060038gorm | https://godoc.org/github.com/jinzhu/gorm
Steve Moyerc2311da2019-01-23 08:34:57 -050039yaml | https://godoc.org/gopkg.in/yaml.v2
40validate | https://github.com/go-playground/validator