Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. func check(F interface{}) bool {
  2. errorInterface := reflect.TypeOf((*error)(nil)).Elem()
  3. if tpFunc := reflect.TypeOf(Func); tpFunc.Kind() != reflect.Func {
  4. return false
  5. } else if tpFunc.NumIn() != 1 || tpFunc.NumOut() != 1 {
  6. return false
  7. } else if tpArg := tpFunc.In(0); tpArg.Kind() != reflect.Ptr || tpArg.Elem().Kind() != reflect.Struct {
  8. return false
  9. } else if tpRet := tpFunc.Out(0); tpRet.Implements(errorInterface) {
  10. return false
  11. }
  12. return true
  13. }
  14.  
  15.  
  16.  
  17. type T0 struct {
  18. A int64
  19. B float
  20. }
  21.  
  22. func F0(t *T0) error {
  23. ...
  24. }
  25.  
  26. func F1(t *T0) int {
  27. ...
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement