removePackage removes a package from the packages field.
(name string)
| 145 | |
| 146 | // removePackage removes a package from the packages field. |
| 147 | func (c *configAST) removePackage(name string) { |
| 148 | switch val := c.packagesField(false).Value.Value.(type) { |
| 149 | case *hujson.Object: |
| 150 | c.removePackageMember(val, name) |
| 151 | case *hujson.Array: |
| 152 | c.removePackageElement(val, name) |
| 153 | default: |
| 154 | panic("packages field must be an object or array") |
| 155 | } |
| 156 | c.root.Format() |
| 157 | } |
| 158 | |
| 159 | func (c *configAST) removePackageMember(pkgs *hujson.Object, name string) { |
| 160 | i := c.memberIndex(pkgs, name) |
no test coverage detected