store

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package store keeps todos in memory. Swap it for a database when you need one; the API stays the same.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned for unknown IDs.

Functions

func Delete

func Delete(id int64) error

Delete removes a todo.

Types

type Todo

type Todo struct {
	ID      int64     `json:"id"`
	Title   string    `json:"title"`
	Done    bool      `json:"done"`
	Created time.Time `json:"created"`
}

Todo is one item.

func Add

func Add(title string) Todo

Add creates a todo.

func Get

func Get(id int64) (Todo, error)

Get returns one todo.

func List

func List(done *bool) []Todo

List returns the todos, optionally only done or open ones.

func Update

func Update(id int64, fn func(*Todo)) (Todo, error)

Update changes a todo with fn.

Jump to

Keyboard shortcuts

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