data

package
v0.0.0-...-0fc5d1f Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func AddProduct

func AddProduct(p *Product)

func DeleteProduct

func DeleteProduct(id int) error

func GetNextID

func GetNextID() int

func UpdateProduct

func UpdateProduct(id int, p *Product) error

Types

type Product

type Product struct {

	// the id for the product
	//
	//requred: false
	// min: 1
	ID int `json:"id"`

	// The name for the product
	//
	// requred: true
	// max length: 255
	Name string `json:"name" validate:"required"`

	// The description of the product
	//
	// required: true
	//max length: 10000
	Description string `json:"description" validate:"required"`

	// requred: true
	// min:0.01
	Price float32 `json:"price" validate:"required,gte=0,lte=10000"`

	// The sku for the product
	//
	// requred:true
	// pattern:[a-z]+-[a-z]+-[1-9]
	SKU string `json:"sku" validate:"required,sku"`

	CreatedAt string `json:"-"`
	UpdatedAt string `json:"-"`
	DeletedAt string `json:"-"`
}

Product defines the structure for an API Product swagger:model

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 (pp *Products) ToJson(w io.Writer) error

Jump to

Keyboard shortcuts

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