feat: deletar produtos

This commit is contained in:
2026-07-15 00:44:32 -03:00
parent 08c83157b1
commit 5eaa6d547f
3 changed files with 31 additions and 1 deletions
+10 -1
View File
@@ -29,6 +29,7 @@ type Inventory struct {
products map[ProductID]Product
}
// função auxiliar para criar a instância do objeto Inventory
func NewInventory() *Inventory {
return &Inventory{products: make(map[ProductID]Product)}
}
@@ -86,4 +87,12 @@ func (e *Inventory) UpdateProduct(id ProductID, field, value string) (*Product,
return &product, nil
}
func (e *Inventory) DeleteProduct() {}
func (e *Inventory) DeleteProduct(id ProductID) error {
if _, ok := e.products[id]; !ok {
return errors.New("Produto não encontrado")
}
delete(e.products, id)
return nil
}