Your map expects a pointer to PaxosInstance ( *PaxosInstance ), but you pass it a struct value. Modify the Initialize function to return a pointer.
func (px *Paxos) InitializePaxosInstance(val interface{}) *PaxosInstance { return &PaxosInstance {decided:false, value: val} }
Now it returns a pointer. You can take the variable pointer with & and (if you ever need to) find it again with * . After a line like
x := &PaxosInstance{}
or
p := PaxosInstance{} x := &p
value type x now *PaxosInstance . And if you ever need it (for any reason), you can dereference it (follow the pointer to the actual value) back to the PaxosInstance struct value with
p = *x
Usually you do not want to pass structures as actual values, because Go is a pass by value, which means that it will copy all of this.
Regarding reading compiler errors, you can see what it told you. The type of PaxosInstance and type *PaxosInstance do not match.
source share