removePatch removes the patch field from the named package.
(name string)
| 219 | |
| 220 | // removePatch removes the patch field from the named package. |
| 221 | func (c *configAST) removePatch(name string) { |
| 222 | pkgs := c.packagesField(false) |
| 223 | obj, ok := pkgs.Value.Value.(*hujson.Object) |
| 224 | if !ok { |
| 225 | // Packages field is an array. |
| 226 | return |
| 227 | } |
| 228 | i := c.memberIndex(obj, name) |
| 229 | if i == -1 { |
| 230 | // Package not found. |
| 231 | return |
| 232 | } |
| 233 | |
| 234 | obj, ok = obj.Members[i].Value.Value.(*hujson.Object) |
| 235 | if !ok { |
| 236 | // Package is a string, not an object. |
| 237 | return |
| 238 | } |
| 239 | i = c.memberIndex(obj, "patch") |
| 240 | if i == -1 { |
| 241 | // Patch field doesn't exist. |
| 242 | return |
| 243 | } |
| 244 | |
| 245 | obj.Members = slices.Delete(obj.Members, i, i+1) |
| 246 | c.root.Format() |
| 247 | } |
| 248 | |
| 249 | // setPatch sets the patch field of the named package. |
| 250 | func (c *configAST) setPatch(name string, mode PatchMode) { |
no test coverage detected