MCPcopy Create free account
hub / github.com/openclaw/gogcli / InferMask

Function InferMask

internal/sheetsformat/format.go:97–125  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

95}
96
97func InferMask(data []byte) (string, []string, error) {
98 var raw map[string]any
99 dec := json.NewDecoder(bytes.NewReader(data))
100 dec.UseNumber()
101
102 if err := dec.Decode(&raw); err != nil {
103 return "", nil, fmt.Errorf("decode format JSON: %w", err)
104 }
105
106 var extra any
107 if err := dec.Decode(&extra); err != io.EOF {
108 if err == nil {
109 return "", nil, errMultipleJSONValues
110 }
111
112 return "", nil, fmt.Errorf("decode trailing format JSON data: %w", err)
113 }
114
115 paths := make([]string, 0)
116 collectJSONLeafPaths("", raw, &paths)
117 sort.Strings(paths)
118
119 if len(paths) == 0 {
120 return "", nil, ValidationError("format JSON did not contain any format fields")
121 }
122 normalized, formatPaths := NormalizeMask(strings.Join(paths, ","))
123
124 return normalized, formatPaths, nil
125}
126
127func ApplyForceSendFields(format *sheets.CellFormat, formatPaths []string) error {
128 if format == nil {

Callers 2

RunMethod · 0.92
TestInferMaskFunction · 0.85

Calls 4

collectJSONLeafPathsFunction · 0.85
NormalizeMaskFunction · 0.85
ErrorfMethod · 0.80
ValidationErrorTypeAlias · 0.70

Tested by 1

TestInferMaskFunction · 0.68