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

Open
opened 2019-12-04 02:29:57 +00:00 by Rainlay · 3 comments

您好,我在撰寫 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.
Author

@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 2021-06-12 08:54:13 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1490
No description provided.