| 13 | } |
| 14 | |
| 15 | func NewMethodInstance(method string, key string, iv string) (MethodInterface, error) { |
| 16 | valueType, ok := methods[method] |
| 17 | if !ok { |
| 18 | return nil, errors.New("method '" + method + "' not found") |
| 19 | } |
| 20 | instance, ok := reflect.New(valueType).Interface().(MethodInterface) |
| 21 | if !ok { |
| 22 | return nil, errors.New("method '" + method + "' must implement MethodInterface") |
| 23 | } |
| 24 | err := instance.Init([]byte(key), []byte(iv)) |
| 25 | return instance, err |
| 26 | } |
| 27 | |
| 28 | func RecoverMethodPanic(err interface{}) error { |
| 29 | if err != nil { |