Go Wiki: 知名结构体标签

背景

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

社区也欢迎并围绕它们构建了 ORM、额外的编码器、标志解析器等,尤其对于这些任务,单一数据源对数据结构来说是有益的。

问题描述

由于 Go 以及 Go 结构体标签 的使用日益增多,冲突变得不可避免。

解决方案

以下列表是尽力记录面向公众的包中使用的知名结构体标签。

列表格式

示例条目

标签 文档
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 的一部分。