I am not sure to understand what you are trying to do, but with reflection, you can see if a field exists or not and then do something with it.
Example derived from the 'laws of reflection' article (http://blog.golang.org/laws-of-reflection). Play: http://play.golang.org/p/neU3j2MYvz
package main
import (
"fmt"
"reflect"
)
type T1 struct {
A int
B string
}
type T2 struct {
A int
}
func fct(i interface{}) {
s := reflect.ValueOf(i).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
if typeOfT.Field(i).Name == "B" {
fmt.Printf("I am %s and I have a field B: %s\n", typeOfT.Name(), f.Interface())
}
}
}
func main() {
t1 := T1{23, "skidoo"}
t2 := T2{23}
fct(&t1)
fct(&t2)
}