lib

package module
v0.0.0-...-a9b0cfc Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const MaxDescriptionLength = 4096
View Source
const MaxNameLength = 2048
View Source
const MaxTagLength = 128
View Source
const MaxTags = 24
View Source
const MaxURLLength = 2048
View Source
const MinQueryLength = 3

Variables

View Source
var (
	// ErrNoUpdate is returned when an update is requested with no updates.
	ErrNoUpdate = errors.New("no update")
	// ErrBookNotFound is returned when a target bookmark was not found.
	ErrBookNotFound = errors.New("bookmark not found")
	// ErrFolderNotFound is returned when a target folder was not found.
	ErrFolderNotFound = errors.New("folder not found")
	// ErrTagNotFound is returned when a target tag was not found.
	ErrTagNotFound = errors.New("tag not found")
	// ErrURLTooShort is returned when a provided URL is too short.
	ErrURLTooShort = errors.New("URL too short")
	// ErrURLTooLong is too long when a provided URL is too long.
	ErrURLTooLong = errors.New("URL too long")
	// ErrNameTooShort is returned when a provided name is too short.
	ErrNameTooShort = errors.New("name too short")
	// ErrNameTooLong is returned when a provided name is too long.
	ErrNameTooLong = errors.New("name too long")
	// ErrDescriptionTooShort is returned when a provided description is too short.
	ErrDescriptionTooShort = errors.New("description too short")
	// ErrDescriptionTooLong is returned when a provided description is too long.
	ErrDescriptionTooLong = errors.New("description too long")
	// ErrTagTooShort is returned when a provided tag is too short.
	ErrTagTooShort = errors.New("tag too short")
	// ErrTagTooLong is returned when a provided tag is too long.
	ErrTagTooLong = errors.New("tag too long")
	// ErrDuplicateTag is returned when a tag is applied twice to a bookmark.
	ErrDuplicateTag = errors.New("tags must be unique")
	// ErrTooManyTags is returned when too many tags have been applied to bookmark.
	ErrTooManyTags = errors.New("too many tags")
	// ErrTagInvalidChar is returned when a provided tag has an invalid character.
	ErrTagInvalidChar = errors.New("tag had invalid chars")
	// ErrFirstTooSmall is returned when a provided first is too small.
	ErrFirstTooSmall = errors.New("first too small")
	// ErrInvalidOrder is returned when a provided order is invalid.
	ErrInvalidOrder = errors.New("invalid order")
	// ErrInvalidDirection is returned when a provided direction is invalid.
	ErrInvalidDirection = errors.New("invalid direction")
	// ErrQueryTooShort is returned when a provided query is too short.
	ErrQueryTooShort = errors.New("query too short")
	// ErrConfigMissing is returned when the config file is missing.
	ErrConfigMissing = errors.New("config missing")
)

Functions

func DefaultAddBookOptions

func DefaultAddBookOptions() addBookOptions

DefaultAddBookOptions are the default options for AddBook.

func DefaultAddFolderOptions

func DefaultAddFolderOptions() addFolderOptions

DefaultAddFolderOptions are the default options for AddFolder.

func DefaultAddTagsOptions

func DefaultAddTagsOptions() addTagsOptions

DefaultAddTagsOptions are the default options for AddTags.

func DefaultListBooksOptions

func DefaultListBooksOptions() listBooksOptions

DefaultListBooksOptions are the default options for ListBooks.

func DefaultListTagsOptions

func DefaultListTagsOptions() listTagsOptions

DefaultListTagsOptions are the default options for ListTags.

func DefaultRemoveBookOptions

func DefaultRemoveBookOptions() removeBookOptions

DefaultRemoveBookOptions are the default options for RemoveBook.

func DefaultRemoveFolderOptions

func DefaultRemoveFolderOptions() removeFolderOptions

DefaultRemoveFolderOptions are the default options for RemoveFolder.

func DefaultRemoveTagsOptions

func DefaultRemoveTagsOptions() removeTagsOptions

DefaultRemoveTagsOptions are the default options for RemoveTags.

func DefaultUpdateBookOptions

func DefaultUpdateBookOptions() updateBookOptions

DefaultUpdateBookOptions are the default options for UpdateBook.

func DefaultUpdateFolderOptions

func DefaultUpdateFolderOptions() updateFolderOptions

DefaultUpdateFolderOptions are the default options for UpdateFolder.

func ListTags

func ListTags(options listTagsOptions) ([]string, error)

ListTags lists tags in the bookmarks database.

func PtrFromNullInt64

func PtrFromNullInt64(num NullInt64) *int64

PtrFromNullInt64 converts a NullInt64 to a *int64. If the NullInt64 is not Valid nil is returned.

func PtrFromNullString

func PtrFromNullString(str NullString) *string

PtrFromNullString converts a NullString to a *string. If the NullString is not Valid nil is returned.

func RemoveBook

func RemoveBook(id string, options removeBookOptions) (err error)

RemoveBook removes a bookmark from the bookmarks database.

func RemoveFolder

func RemoveFolder(id string, options removeFolderOptions) error

RemoveFolder removes a folder from the bookmarks database.

func UpdateConfig

func UpdateConfig(update updateConfigFn) error

UpdateConfig updates the current config. It will be created if it hasn't already been created.

Types

type Book

type Book struct {
	ID          string   // unique identifier of a bookmark/folder
	URL         *string  // address of a bookmark; not used for folders
	Name        string   // name of a bookmark/folder
	Description *string  // description of a bookmark/folder
	ParentID    *string  // optional ID of the parent folder for a bookmark/folder
	IsFolder    bool     // true if folder, and false otherwise
	ParentName  *string  // name of parent folder if bookmark/folder has one
	Tags        []string // tags applied to the bookmark
}

Book is a bookmark or a folder.

func AddBook

func AddBook(url string, options addBookOptions) (Book, error)

AddBook adds a bookmark to the bookmarks database.

func AddFolder

func AddFolder(name string, options addFolderOptions) (Book, error)

AddFolder adds a folder to the bookmarks database.

func AddTags

func AddTags(id string, tags []string, options addTagsOptions) (Book, error)

AddTags adds tags to a bookmark in the bookmarks database.

func ListBooks

func ListBooks(options listBooksOptions) ([]Book, error)

ListBooks lists bookmarks and folders in the bookmarks database.

func RemoveTags

func RemoveTags(id string, tags []string, options removeTagsOptions) (Book, error)

RemoveTags removes tags from a bookmark in the bookmarks database.

func UpdateBook

func UpdateBook(id string, options updateBookOptions) (Book, error)

UpdateBook updates a bookmark in the bookmarks database.

func UpdateFolder

func UpdateFolder(id string, options updateFolderOptions) (Book, error)

UpdateFolder updates a folder in the bookmarks database.

type Config

type Config struct {
	DB string `koanf:"db"`
}

Config is the unmarshalled Config.

func GetConfig

func GetConfig() (Config, error)

GetConfig gets the current config. If the sentinerl error ErrConfigMissing then it doesn't exist.

type Direction

type Direction string

Direction is the direction results are ordered by.

const (
	DirectionAsc  Direction = "asc"
	DirectionDesc Direction = "desc"
)

type NullInt64

type NullInt64 struct {
	sql.NullInt64      // allows use with sql/database and grants null support (null if Valid = false)
	Dirty         bool // tracks if the argument has been provided at all (provided if Dirty = true)
}

NullInt64 is an int64 that can be NULL.

func NullInt64From

func NullInt64From(num int64) NullInt64

NullInt64From converts an int to a NullInt. If the int is zero it will be treated as null. The returned NullInt64 will have Dirty set to true.

func NullInt64FromPtr

func NullInt64FromPtr(num *int64) NullInt64

NullInt64FromPtr converts a *int64 to a NullInt64. If the int64 is nil it will be treated as null. The returned NullInt64 will have Dirty set to true.

func (NullInt64) MarshalJSON

func (s NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON marshalls a NullInt64 to JSON.

func (*NullInt64) UnmarshalJSON

func (s *NullInt64) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls a NullInt64 from JSON.

type NullString

type NullString struct {
	sql.NullString      // allows use with sql/database and grants null support (null if Valid = false)
	Dirty          bool // tracks if the argument has been provided at all (provided if Dirty = true)
}

NullString is a string that can be NULL.

func NullStringFrom

func NullStringFrom(str string) NullString

NullStringFrom converts a string to a NullString. The returned NullString will have Dirty set to true.

func NullStringFromPtr

func NullStringFromPtr(str *string) NullString

NullStringFromPtr converts a *string to a NullString. If the string is nil it will be treated as null. The returned NullString will have Dirty set to true.

func (NullString) MarshalJSON

func (s NullString) MarshalJSON() ([]byte, error)

MarshalJSON marshalls a NullString to JSON.

func (*NullString) UnmarshalJSON

func (s *NullString) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshalls a NullString from JSON.

type Order

type Order string

Order is the field results are ordered on.

const (
	OrderModified Order = "modified"
	OrderName     Order = "name"
)

Jump to

Keyboard shortcuts

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