I have a struct with methods defined in it, i want to iterate through all the methods. Can i use interface {} or any other way to achieve this ?
type SomeStruct struct {
m_boolVals []bool
m_stringVals []string
m_intVals []int64
}
func (m *SomeStruct) GetBool() []bool {
return m.m_boolVals
}
func (m *SomeStruct) GetString() []string {
return m_stringVals
}
func (m *SomeStruct) GetInts() []int64 {
return m_intVals
}
Is there a way to achieve below code ? So basically only one of value would be present
fun SomeOtherFunc(ss *SomeStruct) []string {
var final_string []string
for _, handlerFunc := range(ss.GetBool, ss.GetString, ss.GetInts) {
generic_vals := handlerFunc()
if (len(generic_vals) > 0) {
for _, t_val := range(generic_vals) {
final_string = append(final_string , string(t_val))
}
break
}
}
return final_string
}