You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import"github.com/meannanov/fmutils"funcPatchList(currentColorMyColor, newColorMyColor, paths []string) (&MyColor, error) {
fieldMask:=&field_mask.FieldMask{
Paths: paths,
}
fieldMask.Normalize()
if!fieldMask.IsValid(¤tColor) {
returnnil, fmt.Errorf("invalid fields passed in patch:%+v", paths)
}
// Redact the newColor to keep only the fields provided for patchfmutils.Filter(&newColor, fieldMask.GetPaths())
// Need to prune the currenColor for not affecting the non mentioned fields in field-mask during mergefmutils.Prune(¤tColor, fieldMask.GetPaths())
// merges the existing object to have the patched fields' dataproto.Merge(¤tColor, &newColor)
return¤tColor, nil
}
funcmain() {
myColors:=MyColors{
colors: []Color{"blue", "green", "white"},
}
// want to patch 1st index of newColor to myColorpatchedColor:=PatchList(myColor, newColor, []string{"colors[1]"})
}
Proto
Go Types for Proto
Feature request
Protobuf at present does not support it protocolbuffers/protobuf#8547 but this would be really helpful
The text was updated successfully, but these errors were encountered: