一次執行多組 test case 遇到 encoding/gob.RegisterName Error #1490

Open
opened 2 years ago by Rainlay · 3 comments
Rainlay commented 2 years ago

您好,我在撰寫 unit test 時,分別獨立執行是不會有問題的,但一次 run 整個 package 測試則會發生以下錯誤:

panic: gob: registering duplicate names for *models.Friend: "xxx-go/models.Friend" != "*models.Friend" [recovered]

panic: gob: registering duplicate names for *models.Friend: "xxx-go/models.Friend" != "*models.Friend"

ps: 其中一組 test 是單獨 insert, 另一組是批次 insert

您好,我在撰寫 unit test 時,分別獨立執行是不會有問題的,但一次 run 整個 package 測試則會發生以下錯誤: panic: gob: registering duplicate names for *models.Friend: "xxx-go/models.Friend" != "*models.Friend" [recovered] panic: gob: registering duplicate names for *models.Friend: "xxx-go/models.Friend" != "*models.Friend" ps: 其中一組 test 是單獨 insert, 另一組是批次 insert
Owner

@Rainlay You cannot register the same name struct on an engine. xxx-go/models.Friend and models.Friend have the same name.

@Rainlay You cannot register the same name struct on an engine. `xxx-go/models.Friend` and `models.Friend` have the same name.
Poster

@lunny can you explain how to avoid this situation, I know is duplicate register, but I am not sure why this happened.

@lunny can you explain how to avoid this situation, I know is duplicate register, but I am not sure why this happened.
Owner

Because we use gob to register struct but it doesn't allow duplicated name.

Because we use gob to register struct but it doesn't allow duplicated name.
lunny added the
need/feedback
label 6 months ago
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.