This repository has been archived on 2025-07-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
eternos/internal/products/service.go
2025-01-04 14:04:53 +03:00

28 lines
727 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package products
// Product - структура для товара
type Product struct {
Name string
Price float64
}
// ProductService - сервис для работы с товарами
type ProductService struct {
products []Product
}
// NewProductService - создание нового экземпляра ProductService
func NewProductService() *ProductService {
return &ProductService{}
}
// AddProduct - добавление товара в сервис
func (s *ProductService) AddProduct(product Product) {
s.products = append(s.products, product)
}
// GetAllProducts - получение списка всех товаров
func (s *ProductService) GetAllProducts() []Product {
return s.products
}