data

package
v0.0.0-...-9c35b0d Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Product

type Product struct {
	ID          int     `json:"id"`
	Name        string  `json:"name"`
	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

type Products

type Products []*Product

Products is a collection of Product

func GetProducts

func GetProducts() Products

GetProducts returns a list of products

func (*Products) ToJSON

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

ToJSON serializes the contents of the collection to JSON NewEncoder provides better performance than json.Unmarshal as it does not have to buffer the output into an in memory slice of bytes this reduces allocations and the overheads of the service

https://golang.org/pkg/encoding/json/#NewEncoder

Jump to

Keyboard shortcuts

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