Hey @Deimis, you probably want a type switch if I understand your question correctly:
package main
import "fmt"
type MyObjOne struct {
id int
val int
}
type MyObjTwo struct {
id int
val int
}
func ObjectOutput(obj interface{}) string {
switch o := obj.(type) {
case MyObjOne:
return fmt.Sprintf("MyObjOne, id: %d, val %d", o.id, o.val)
case MyObjTwo:
return fmt.Sprintf("MyObjTwo, id: %d, val %d", o.id, o.val)
}
return ""
}
func main() {
m1 := MyObjOne{1, 2}
m2 := MyObjTwo{3, 4}
fmt.Println(ObjectOutput(m1))
fmt.Println(ObjectOutput(m2))
}