I’ve a function which should do something like this
func getA(m *m.TSR, bl string) string {
runParams, exist := m.BuildParams.Before[bl]
if exist {
runParamsMap, ok := runParams.(map[interface{}]interface{})
if ok {
run, ok := runParamsMap["builder"]
if ok {
return run.(string)
}
}
}
return ""
}
func getB(m *m.TSR, bl string) string {
runParams, exist := m.BuildParams.After[bl]
if exist {
runParamsMap, ok := runParams.(map[interface{}]interface{})
if ok {
run, ok := runParamsMap["builder"]
if ok {
return run.(string)
}
}
}
return ""
}
Both function are working as expected , but I wonder if there is a way to use just only one function that handle the same ? The only difference is the Before & After
m.BuildParams.Before[bl]
m.BuildParams.After[bl]
All the reset is exactly the same, any idea how to combine them without removing the those line outside the function ….
maybe with additional parameter ....