data

package
v0.0.0-...-7cb54bc Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProductNotFound = fmt.Errorf("Product Not Foound")

Functions

func AddProduct

func AddProduct(p *Product) int

func FromJson

func FromJson(v interface{}, r io.Reader) error

func ToJson

func ToJson(v interface{}, w io.Writer) error

func UpdateProduct

func UpdateProduct(id int, p *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:"gt=0"`
	SKU         string  `json:"sku" validate:"required,sku"`
	CreatedOn   string  `json:"-"`
	UpdatedOn   string  `json:"-"`
	DeletedOn   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