data

package
v0.0.0-...-fb460ba Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrProductNotFound = fmt.Errorf("Product not found")

Functions

func AddProduct

func AddProduct(p *Product)

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"`
	SKU         string  `json:"sku"`
	CreatedOn   string  `json:"-"`
	UpdatedOn   string  `json:"-"`
	DeletedOn   string  `json:"-"`
}

Product defines the structure for an API product

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