after reading my post i thought i try to explain that interface thing better look at following example:
type Fighter interface{
Fight() bool //finding out if all consitions are met to actually fight
}
type Rebel struct{
Idelogy string
}
type Mercenary struct{
Payment int
}
func(r *Rebel)Fight()bool{
// will fight if he is inclined to do so
return r.Ideology=="Militaristic"
}
func(m *MercenaryFight()bool{
// will fight if he gets more than 2000 Dollar
return m.Payment > 2000
}
func WillHeFight(fs Fighter)bool{
return fs.Fight()
this is not a complete Program it's just to see how an arbitrary data structure by implementing functions can be used as a certain type
in this case Fighter.