tab

package
v0.0.0-...-db5681a Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//存储库返回的错误
	ErrRepoNextID = errors.New("tab: could not return next id")
	ErrRepoList   = errors.New("tab: could not list")
	ErrNotFound   = errors.New("tab: could not find")
	ErrRepoGet    = errors.New("tab: could not get")
	ErrRepoAdd    = errors.New("tab: could not add")
	ErrRepoRemove = errors.New("tab: could not remove")
)
View Source
var (
	// 给出无效标题时使用的错误
	ErrInvalidTitle  = errors.New("tab: could not use invalid title")
	ErrTitleTooShort = fmt.Errorf("%s: min length allowed is %d", ErrInvalidTitle, minTitleLength)
	ErrTitleTooLong  = fmt.Errorf("%s: max length allowed is %d", ErrInvalidTitle, maxTitleLength)
)

Functions

This section is empty.

Types

type ID

type ID int

type Repo

type Repo interface {
	//NextID 返回下一个空闲 ID 并在失败时返回错误
	NextID() (ID, error)
	// 列表返回一个选项卡切片并在失败的情况下返回一个错误
	List() ([]*Tab, error)
	// Find 返回一个 tab 或者 nil ,如果它没有找到并且在失败的情况下,则返回一个错误
	Find(ID) (*Tab, error)
	// 如果未找到或失败,则获取返回选项卡和错误
	Get(ID) (*Tab, error)
	// 添加持久化选项卡(已经存在或不存在)并在失败时返回错误
	Add(*Tab) error
	// 删除选项卡并返回并在未找到或失败的情况下出错
	Remove(ID) error
}

type Tab

type Tab struct {
	ID          int
	Title       Title
	Description string
	Icon        string
	Link        string
	Created     time.Time
	Updated     time.Time
}

Tab 代表一个标签

func New

func New(id int, title Title, description string, icon string, link string) *Tab

New 返回第一次创建的标签

func (*Tab) Update

func (t *Tab) Update(title Title, description string, icon string, link string)

Update 使用新属性更新标签

type Title

type Title string

Title 代表标签标题

func NewTitle

func NewTitle(d string) (Title, error)

NewTitle 返回标题和错误

func (Title) Equals

func (t Title) Equals(t2 Title) bool

Equals 如果标题相等,则返回 true

func (Title) String

func (t Title) String() string

String 返回标题的字符串表示

Jump to

Keyboard shortcuts

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