I have the following interface:
type ExampleInterface interface{
GetFirstItemInSlice()
}
func GetFirstItemInSlice(slice ExampleInterface){
slice.GetFirstItemInSlice()
}
func (slice IntSlice) GetFirstItemInSlice(){
// Omitted for brevity.
}
func (slice StringSlice) GetFirstItemInSlice(){
// Omitted for brevity.
}
Now, it is clear here, that my two functions which have recievers (the bottom two), will want to return different types, one a string, and the other, an int. If I just tack on a return type, then it will break my interface, right?
I assume this is a common problem, and I am missing some key knowledge component on interfaces, All help appreciated.
Please note : I would rather not return an interface, I would REALLY love to return a piece of typed data.