Documentation ¶
Index ¶
- func Close()
- func CreateTable() (err error)
- func DeleteNumber(phn PhoneNumber, msg string) (err error)
- func InsertNumber(value string) (uid int64, err error)
- func Normalize(numbers []PhoneNumber) error
- func Open() (err error)
- func UpdateNumber(phn PhoneNumber, new string) (err error)
- type PhoneNumber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTable ¶
func CreateTable() (err error)
CreateTable runs a query to create a table to store phone number data.
func DeleteNumber ¶
func DeleteNumber(phn PhoneNumber, msg string) (err error)
DeleteNumber deletes given phone number from database
func InsertNumber ¶
InsertNumber inserts given phone number into database and returns uid.
func Normalize ¶
func Normalize(numbers []PhoneNumber) error
Normalize iterates over all the numbers from database and normalizes them.
func Open ¶
func Open() (err error)
Open creates a new sqlite database file, returns the pointer to database.
func UpdateNumber ¶
func UpdateNumber(phn PhoneNumber, new string) (err error)
UpdateNumber updates new val at given uid, else returns error.
Types ¶
type PhoneNumber ¶
PhoneNumber is Go representation for phone_number table in database.
func FindNumber ¶
func FindNumber(val string) (*PhoneNumber, error)
FindNumber looks up given number in database and returns matched row
func SelectAll ¶
func SelectAll() ([]PhoneNumber, error)
SelectAll fetches all the rows from phone_numbers table.
func (PhoneNumber) Format ¶
func (pn PhoneNumber) Format() string
Format displays the phone number in "(223) 456-7890" format.