able to parse xml

This commit is contained in:
2024-01-28 16:49:48 +03:00
parent 90a7797a27
commit bfa105df95
12 changed files with 298 additions and 89 deletions

View File

@ -45,15 +45,6 @@ type GoodsItemRaw struct {
type MappedGoodsRemnants map[int]GoodsRemnant
type GoodsRemnant [4]int32
func ExtractProductIDs(items []GoodsItem) (out []int) {
out = make([]int, 0, len(items))
for _, item := range items {
out = append(out, int(item.Cart))
}
return out
}
func MakeGoodsItem(
gi GoodsItemRaw,
remnants MappedGoodsRemnants,

28
internal/entity/iter.go Normal file
View File

@ -0,0 +1,28 @@
package entity
func IterWithErr[T any](t []T, err error) iterWithErr[T] {
return iterWithErr[T]{
items: t,
err: err,
}
}
type iterWithErr[T any] struct {
items []T
err error
}
func (iter iterWithErr[T]) Do(f func(T) error) error {
if iter.err != nil {
return iter.err
}
for _, item := range iter.items {
err := f(item)
if err != nil {
return err
}
}
return nil
}