mennanov / fieldmask-utils

Protobuf Field Mask Go utils
MIT License
229 stars 26 forks source link

add support of dst structs with pointers #22

Closed propan closed 2 years ago

propan commented 2 years ago

Hi!

It would be great to support copying to structs that use pointers to the same types, e.g.:

type ChangedUser {
    Name *string
    Age *int
}

var request UpdateUserRequest
dst := &ChangedUser{}// a struct to copy to
mask, err := fieldmask_utils.MaskFromPaths(request.FieldMask.Paths, generator.CamelCase)
// handle err...
fieldmask_utils.StructToStruct(mask, request.User, dst)

Thanks!

codecov[bot] commented 2 years ago

Codecov Report

Merging #22 (aefe6e7) into master (45198b5) will increase coverage by 0.76%. The diff coverage is 92.59%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #22      +/-   ##
==========================================
+ Coverage   88.08%   88.85%   +0.76%     
==========================================
  Files           2        2              
  Lines         319      341      +22     
==========================================
+ Hits          281      303      +22     
  Misses         20       20              
  Partials       18       18              
Impacted Files Coverage Δ
copy.go 85.20% <92.59%> (+1.61%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 45198b5...aefe6e7. Read the comment docs.

mennanov commented 2 years ago

Thanks!