github.com/wfusion/gofusion@v1.1.14/common/infra/watermill/components/cqrs/object.go (about) 1 package cqrs 2 3 import ( 4 "reflect" 5 ) 6 7 func isPointer(v any) error { 8 rv := reflect.ValueOf(v) 9 10 if rv.Kind() != reflect.Ptr || rv.IsNil() { 11 return NonPointerError{rv.Type()} 12 } 13 14 return nil 15 } 16 17 type NonPointerError struct { 18 Type reflect.Type 19 } 20 21 func (e NonPointerError) Error() string { 22 return "non-pointer command: " + e.Type.String() + ", handler.NewCommand() should return pointer to the command" 23 }