Documentation ¶
Index ¶
- Constants
- Variables
- func Path() string
- func Sort(element sortBy, items []*Item, reversed bool)
- type Item
- func (i *Item) LocationPicture() (image.Image, error)
- func (i *Item) Picture() (image.Image, error)
- func (i *Item) SetLocationPicture(r io.ReadSeeker) error
- func (i *Item) SetPicture(r io.ReadSeeker) error
- func (i *Item) String() string
- func (i *Item) Update() error
- func (i *Item) Use(who string) error
Constants ¶
View Source
const ( // ByName sorts items by name. ByName sortBy = (1 << iota) // ByDate sorts items by update date. ByDate // ByPrice sorts items by price. ByPrice // ByInUse sorts items by use state. ByInUse // ByInUseDate sorts items by use state first and update date second. ByInUseDate )
Variables ¶
View Source
var ( // CustomPath sets a custom directory to store the inventory. CustomPath string // ReturnLocation sets the return location of the inventory (default: // returned). ReturnLocation = "returned" )
Functions ¶
Types ¶
type Item ¶
type Item struct { ID string `yaml:"id"` Name string `yaml:"name"` Price string `yaml:"price"` Location string `yaml:"location"` Updated time.Time `yaml:"update"` InUse bool `yaml:"borrowed"` }
Item is the item in the inventory.
func Add ¶
Add adds a new named item to the inventory. It will auto-generate a unique ID for the item based on the name.
func SortedItems ¶
SortedItems returns a sorted slice of items in the inventory.
func (*Item) LocationPicture ¶
LocationPicture returns the picture of the location associated with the item.
func (*Item) SetLocationPicture ¶
func (i *Item) SetLocationPicture(r io.ReadSeeker) error
SetLocationPicture sets the thumbnail picture of the item. To save space, the image is resized within 1000x1000 pixels and encoded as jpeg.
func (*Item) SetPicture ¶
func (i *Item) SetPicture(r io.ReadSeeker) error
SetPicture sets the thumbnail picture of the item. To save space, the image is resized within 1000x1000 pixels and encoded as jpeg.
Click to show internal directories.
Click to hide internal directories.