puppy

package
v0.0.0-...-cf576ff Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNegativePuppyID = 400
	ErrPuppyNotFound   = 404
)

Error codes

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Message string
	Code    int
}

Error (our custom error type) wraps errors with code, message and error itself - what does this even mean??

func (*Error) Error

func (e *Error) Error() string

Error() method lets us satisfy error interface for our custom error type

type Puppy

type Puppy struct {
	ID     int
	Breed  string
	Colour string
	Value  float64
}

Puppy data structure stores puppy properties

type Storer

type Storer interface {
	CreatePuppy(puppy *Puppy) (int, error) // takes a pointer which makes sense since you are modifying that object
	ReadPuppy(id int) (*Puppy, error)
	UpdatePuppy(id int, puppy *Puppy) error
	DeletePuppy(id int) error
}

Storer defines standard CRUD operations for Pets

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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