LoginSignup
1
0

More than 1 year has passed since last update.

【Gorm✕firestoreで構造体の大文字が変換されない対処法】

Posted at

Gormからfirestoreにデータを保存する際、タグをつけなければ構造体の大文字のままキーが設定されてしまったので、対処法を記述する。

単純に、firestore:"name" のようなタグを構造体に付与すればいい。

type User struct {
    Name                 string  `json:"name" firestore:"name"`
    Email                string  `json:"email" firestore:"email"`
}

ドキュメントしっかり読もう。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0