package vote import ( "fmt" "time" ) type Vote struct { Id string Elector string Choice Choice timestamp time.Time } func NewVote(id, elector string, choice Choice) Vote { return Vote{ Id: id, Elector: elector, Choice: choice, timestamp: time.Now().UTC(), } } func NewVoteWithTimestamp(id, elector string, choice Choice, timestamp time.Time) Vote { return Vote{ Id: id, Elector: elector, Choice: choice, timestamp: timestamp, } } func (vote Vote) String() string { return fmt.Sprintf("%s %s %s %s", vote.Id, vote.timestamp.Format(time.DateTime), vote.Choice, vote.Elector) }