contacts

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contact

type Contact struct {
	Email   string    `json:"email"`
	Name    string    `json:"name,omitempty"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Contact represents a single address book entry.

type Store

type Store struct {
	Contacts []Contact `json:"contacts"`
	// contains filtered or unexported fields
}

Store manages the contacts address book.

func Load

func Load() (*Store, error)

Load reads the contacts store from disk.

func (*Store) Add

func (s *Store) Add(email, name string) error

Add creates a new contact. Returns error if email already exists.

func (*Store) Count

func (s *Store) Count() int

Count returns the number of contacts.

func (*Store) Get

func (s *Store) Get(email string) *Contact

Get retrieves a contact by email. Returns nil if not found.

func (*Store) List

func (s *Store) List() []Contact

List returns all contacts, optionally sorted by name or email.

func (*Store) Remove

func (s *Store) Remove(email string) error

Remove deletes a contact by email. Returns error if not found.

func (*Store) Save

func (s *Store) Save() error

Save writes the contacts store to disk.

func (*Store) Search

func (s *Store) Search(query string) []Contact

Search finds contacts matching the query string. Searches both name and email fields (case-insensitive).

func (*Store) Update

func (s *Store) Update(email, name string) error

Update modifies an existing contact's name.

Jump to

Keyboard shortcuts

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