golang / protobuf

Go support for Google's protocol buffers
BSD 3-Clause "New" or "Revised" License
9.74k stars 1.58k forks source link

Is it possible to reduce the fieldmask to some path depth? #1518

Open nickolation opened 1 year ago

nickolation commented 1 year ago

For example, I have a fieldmask with paths = {a.b.c, a.b, a.x.d, a.g.f} I want to transform all paths containing more than 3 nodes so that only the first 2 nodes remain in them. Then remove the matches. In result i want {a.b, a.x, a.g} Is there an opportunity to do something like this?

stapelberg commented 1 year ago

This question sounds like an XY problem: http://mywiki.wooledge.org/XyProblem

Can you supply an example program that illustrates as much as possible what you’re trying to do?

The way your question is currently worded, I could say “sure, just remove everything after the first 2 dots”. I’m not sure if the problem you’re facing is that the number of dots is variable, or something else entirely…?