Documentation ¶
Index ¶
- func NextTimeID() string
- func RandomID() string
- func TimeID() string
- func TimeNow() string
- type IncreaseID
- type Note
- func (note *Note) AddPatch(patch string) error
- func (note *Note) AddPatchNow(patch, contents string) error
- func (note *Note) AddPatchSetTitle(patch, contents string) error
- func (note *Note) SetNewTags(tagNames []string) error
- func (note *Note) SetTitle(contents string)
- func (note *Note) UpdateTitleSizeNow(title string, patchSize int) error
- type NoteType
- type OldNote
- type Patch
- type Tag
- type TagGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NextTimeID ¶
func NextTimeID() string
Types ¶
type IncreaseID ¶
IncreaseID 用来记录自动生成 ID 的状态,便于生成特有的自增 ID. 该 ID 由年份与自增数两部分组成,分别取两个部分的 36 进制, 转字符串后拼接而成。
func FirstID ¶
func FirstID() IncreaseID
FirstID 生成初始 id, 当且仅当程序每一次使用时(数据库为空时)使用该函数, 之后应使用 Increase 函数来获得新 id.
func ParseID ¶
func ParseID(strID string) (id IncreaseID, err error)
ParseID 把字符串形式的 id 转换为 IncreaseID. (有“万年虫”问题,但是当然,这个问题可以忽略。)
func (IncreaseID) Increase ¶
func (id IncreaseID) Increase() IncreaseID
Increase 使 id 自增一次,输出自增后的新 id. 如果当前年份大于 id 中的年份,则年份进位,Count 重新计数。 否则,年份不变,Count 加一。
type Note ¶
type Note struct { ID string // primary key Type NoteType Title string Patches []string Size int Tags []tagset.Tag Deleted bool RemindAt string // ISO8601 CreatedAt string UpdatedAt string }
func NewNote ¶
func NewNote(id, title, patch, remindAt string, noteType NoteType, tagNames []string) ( *Note, error)
NewNote .
func (*Note) AddPatchNow ¶
AddPatchNow combines AddPatchSetTitle and UpdatedAtNow.
func (*Note) AddPatchSetTitle ¶
AddPatchSetTitle .
func (*Note) SetNewTags ¶
SetNewTags 对标签进行一些验证和处理(例如除重和排序)。 尽量不要直接操作 note.Tags
type Patch ¶
type Patch = diffmatchpatch.Patch
Click to show internal directories.
Click to hide internal directories.