我有一個用戶類型:type User struct { Username string Email string Password string}還有一個帖子類型:type Post struct { User // how to define here? Title string Content string}帖子實體看起來像:用戶:密鑰(用戶,'10000')標題:“有些傾斜”內容:“一些內容”怎么定義Post.User?
1 回答

叮當貓咪
TA貢獻1776條經驗 獲得超12個贊
由于您的Post
實體包含完整的Key
s,因此用作datastore.Key
字段類型:
type Post struct {
? ? User? ? *datastore.Key
? ? Title? ?string
? ? Content string
}
- 1 回答
- 0 關注
- 128 瀏覽
添加回答
舉報
0/150
提交
取消