Basically i'm checking whether the second input argument is of type
Context (which is a struct).
I did consider using reflect.AssignableTo(), however that takes a Type as
input, so in order to get the type i have to actually create an instance of
Context to pass to reflect.TypeOf(). So that seems like a waste of
resources, so i ended up with this:
// t = reflect.Type
//TODO is this _really_ a good check? naw..
if name := t.In(1).Name(); name != "Context" {
panic(fmt.Sprintf("Expected 'Context' as input argument, not: %s", name))
}
The reason why i don't like this check is that "Context" is hardcoded in
there, so that would break if the struct Context ever changed name but not
at compile time, which is preferred.
So any opinions on how this can be improved?
Much appreciated
Sincerely Kim
--