gitlab.com/evatix-go/core@v1.3.55/coredata/corejson/NewPtr.go (about) 1 package corejson 2 3 import ( 4 "encoding/json" 5 6 "gitlab.com/evatix-go/core/errcore" 7 "gitlab.com/evatix-go/core/internal/reflectinternal" 8 ) 9 10 func NewPtr(anyItem interface{}) *Result { 11 jsonBytes, err := json.Marshal(anyItem) 12 typeName := reflectinternal.TypeName(anyItem) 13 14 if err != nil { 15 return &Result{ 16 Bytes: jsonBytes, 17 Error: errcore.MarshallingFailedType.Error( 18 err.Error(), 19 typeName), 20 TypeName: typeName, 21 } 22 } 23 24 return &Result{ 25 Bytes: jsonBytes, 26 Error: err, 27 TypeName: typeName, 28 } 29 }