#Whats this error
24 messages · Page 1 of 1 (latest)
share the full error message
i missed the first part
my bad
func (v voters) record_preferences() error {
_, voted := global_ranking[v.name]
if voted {
return errors.New("Voter voted")
}
// fmt.Println(v.votes)
fmt.Println(v.votes)
global_ranking[v.name] = v.votes
return nil
}
i think its in this part
type global_ranks map[voter_name]voter_ranks
var global_ranking global_ranks
try this
func (v *voters) record_preferences() error {
_, voted := global_ranking[v.name]
if voted {
return errors.New("Voter voted")
}
// fmt.Println(v.votes)
fmt.Println(v.votes)
global_ranking[v.name] = v.votes
return nil
}
no
its interesting that receiving from nil map does not cause error.
probably because of the second bool variable _, voted :=
(its not)
My hunch might have to use something like this
m := make(map[string]interface{})
see the error goes away if i take way the assigment to global rankings
i found this
i think
its cause of the nil map assignment
Okay. can you paste the code having changes that fixed the issue. would like to retrospect it.
var global_ranking = global_ranks{}
yep
this
fixed the panic error
so this initializes the map i assume