data

package
v0.0.0-...-4f2580d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProductNotFound = errors.New("product not found")

Functions

func AddProduct

func AddProduct(prod *Product)

func DeleteProduct

func DeleteProduct(id int) error

func UpdateProduct

func UpdateProduct(id int, prod *Product) error

Types

type Product

type Product struct {
	ID          int     `json:"id"`
	Name        string  `json:"name" validate:"required"`
	Description string  `json:"description"`
	Price       float32 `json:"price" validate:"gte=0"`
	SKU         string  `json:"sku" validate:"required, sku"`
	CreatedOn   string  `json:"-"`
	UpdatedOn   string  `json:"-"`
	DeleteOn    string  `json:"-"`
}

func (*Product) FromJson

func (p *Product) FromJson(r io.Reader) error

func (*Product) Validate

func (p *Product) Validate() error

type Products

type Products []*Product

func GetProducts

func GetProducts() Products

func (*Products) ToJson

func (p *Products) ToJson(w io.Writer) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL