From 91069fa5b67c0fb5fb0f715b8ab28b14ac1e238c Mon Sep 17 00:00:00 2001 From: David Florness Date: Sun, 13 Mar 2022 14:36:53 -0400 Subject: [PATCH] Log reading and unmarshalling of elections file --- cmd/tallyard/main.go | 4 +++- election/map.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/tallyard/main.go b/cmd/tallyard/main.go index 3eb58f4..be78681 100644 --- a/cmd/tallyard/main.go +++ b/cmd/tallyard/main.go @@ -269,12 +269,14 @@ func getElections(userID id.UserID) (*election.ElectionsMap, error) { return nil, fmt.Errorf("couldn't stat elections file: %s", err) } + log.Info("reading elections file...") jsonBytes, err := ioutil.ReadFile(electionsFname) if err != nil { return nil, fmt.Errorf("couldn't read elections file: %s", err) } - em, err := election.ReadElectionsMapFrom(jsonBytes, userID, saveElections) + log.Info("unmarshalling elections file...") + em, err := election.UnmarshalElectionsMapFrom(jsonBytes, userID, saveElections) if err != nil { return nil, fmt.Errorf("couldn't read elections map: %s", err) } diff --git a/election/map.go b/election/map.go index c158558..48f6699 100644 --- a/election/map.go +++ b/election/map.go @@ -41,7 +41,7 @@ func NewElectionsMap(userID id.UserID, save func(*ElectionsMap)) *ElectionsMap { } } -func ReadElectionsMapFrom(jsonBytes []byte, userID id.UserID, save func(*ElectionsMap)) (*ElectionsMap, error) { +func UnmarshalElectionsMapFrom(jsonBytes []byte, userID id.UserID, save func(*ElectionsMap)) (*ElectionsMap, error) { em := &ElectionsMap{} err := json.Unmarshal(jsonBytes, em) if err != nil { -- 2.38.4