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 的一部分。