Um.. under the column of "missing something obvious", since the interface type you are comparing it to is KNOWN, is there a reason why you can't:
type T interface {
DoSomething()
}
// Let the compiler handle it
func fn (arg T) {
}
Or if you are making a function that takes different sets of parameters:
type U interface {
DoSomethingElse()
}
// Use a type switch
func fn2 (arg interface{}) {
switch v := arg.(type) {
case T: v.DoSomething()
case U: v.DoSomethingElse()
}
}
// Use type assertions
func fn3 (arg interface{}) {
if t, ok := arg.(T) ; ok {
t.DoSomething()
}
if u, ok := arg.(U) ; ok {
u.DoSomethingElse()
}
}
Unless of course, you are using values to which you don't know the types you want to check. (You did say "known interface X")