Files
go-cart-actor/pkg/cart/mutation_markings.go
mats dddb5c699a
Build and Publish / BuildAndDeployAmd64 (push) Failing after 4s
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s
same stuff?
2026-07-03 23:11:25 +02:00

33 lines
805 B
Go

package cart
import (
"fmt"
messages "git.k6n.net/mats/go-cart-actor/proto/cart"
)
// LineItemMarking sets a marking on the line item with the given ID.
func LineItemMarking(grain *CartGrain, req *messages.LineItemMarking) error {
for i, item := range grain.Items {
if item.Id == req.Id {
grain.Items[i].Marking = &Marking{
Type: req.Type,
Text: req.Marking,
}
return nil
}
}
return fmt.Errorf("item with ID %d not found", req.Id)
}
// RemoveLineItemMarking clears the marking on the line item with the given ID.
func RemoveLineItemMarking(grain *CartGrain, req *messages.RemoveLineItemMarking) error {
for i, item := range grain.Items {
if item.Id == req.Id {
grain.Items[i].Marking = nil
return nil
}
}
return fmt.Errorf("item with ID %d not found", req.Id)
}