Go Wiki:知名结构体标签

背景

Go 提供了 结构体标签(struct tags),可以通过反射发现它们。这些标签在标准库的 JSON/XML 和其他编码包中得到了广泛应用。

社区很欢迎它们,并围绕它们构建了 ORM、其他编码库、标志解析器等等,尤其是在这些任务中,数据结构采用单一来源是有益的。

问题描述

由于 Go 的使用量增加以及 Go 结构体标签(struct tags) 的广泛使用,冲突变得不可避免。

解决方案

以下列表旨在尽力记录公共包中使用的知名结构体标签。

列表格式

示例条目

标签 文档
xml https://pkg.go.dev/encoding/xml

变更管理

任何创建使用新标签的公共包的人都可以添加列表条目。当指向包文档的链接失效或该包的作者请求时,可以删除列表条目。

知名结构体标签列表

标签 文档
asn1 https://pkg.go.dev/encoding/asn1
bigquery https://pkg.go.dev/cloud.google.com/go/bigquery
bson https://pkg.go.dev/go.mongodb.org/mongo-driver/bson
cue https://pkg.go.dev/cuelang.org/go/cuego
datastore https://pkg.go.dev/cloud.google.com/go/datastore
db https://github.com/jmoiron/sqlx
dynamodbav https://docs.aws.amazon.com/sdk-for-go/api/service/dynamodb/dynamodbattribute/#Marshal
egg https://github.com/andrewwphillips/eggql
feature https://github.com/nikolaydubina/go-featureprocessing
gorm https://pkg.go.dev/github.com/jinzhu/gorm
graphql https://github.com/samsarahq/thunder
json https://pkg.go.dev/encoding/json
mapstructure https://pkg.go.dev/github.com/mitchellh/mapstructure
parser https://pkg.go.dev/github.com/alecthomas/participle
properties https://pkg.go.dev/github.com/magiconair/properties#Properties.Decode
protobuf https://github.com/golang/protobuf
reform https://pkg.go.dev/gopkg.in/reform.v1
spanner https://pkg.go.dev/cloud.google.com/go/spanner
toml https://pkg.go.dev/github.com/pelletier/go-toml
url https://github.com/google/go-querystring
validate https://github.com/go-playground/validator
xml https://pkg.go.dev/encoding/xml
yaml https://pkg.go.dev/gopkg.in/yaml.v2

此内容是 Go Wiki 的一部分。