Go Wiki: 既知の構造体タグ

背景

Go は、リフレクションを介して検出可能な構造体タグを提供しています。これらは、JSON/XML やその他のエンコーディングパッケージの標準ライブラリで幅広く使用されています。

コミュニティはこれらを歓迎し、特にデータ構造のシングルソーシングが有益なこれらのタスクのために、ORM、さらなるエンコーディング、フラグパーサーなどを構築してきました。

問題の説明

Go の使用、ひいては Go の構造体タグの使用が増加したため、衝突は避けられなくなりました。

解決策

以下のリストは、一般に公開されているパッケージで使用されている既知の構造体タグを文書化するための最善の努力です。

リストの形式

エントリの例

タグ ドキュメント
xml https://pkg.go.dev/encoding/xml

変更管理

リストエントリは、新しいタグが使用されるパブリックパッケージを作成した人なら誰でも追加できます。パッケージドキュメントへのリンクが機能しなくなった場合、またはそのパッケージの作成者がリクエストした場合、リストエントリを削除できます。

既知の構造体タグのリスト

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

このコンテンツはGo Wikiの一部です。