In golang I am trying to create a function which I want to call it with an object of a structure.
How can I make the function accept calls from all types of structures.
calling function:
func (this PortStatsHandler) triggerSampler(counter int) {
portstatob.GenerateStats(ctime) //portstatob is an object.
}
function:
func (this *PortStats) GenerateStats(ctime time.Time) {
}
Now it's accepting only objects of PortStats
but not any structure.
Unfortunately go doesn't have generics and the answer to your question is - it's impossible.
The only thing you can do here is create regular function and pass object into function as parameter.