From a87dc50873517fa0023c488827000d183462dd64 Mon Sep 17 00:00:00 2001 From: David Florness Date: Tue, 19 Jan 2021 18:00:20 -0500 Subject: [PATCH] Fix Election JSON marshalling This prevents an infinite loop. --- election/election.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/election/election.go b/election/election.go index d82c549..8d2deee 100644 --- a/election/election.go +++ b/election/election.go @@ -39,7 +39,10 @@ func NewElection(candidates []Candidate, createEventId id.EventID, } func (el *Election) UnmarshalJSON(b []byte) error { - err := json.Unmarshal(b, &el) + type Alias Election // create alias to prevent endless loop + tmp := (*Alias)(el) + + err := json.Unmarshal(b, tmp) if err != nil { return err } -- 2.38.4