Documentation ¶
Index ¶
Constants ¶
const ( // GosendZip 是自定义的文件类型,表示自动打包的文件,避免重复打包。 GosendZip = "gosend/zip" // GosendAnchor 是自定义的文件类型,但不用于文件,而是用于 TextMsg, // 表示该文本内容是网址 (html 的 a 标签) GosendAnchor = "gosend/anchor" )
const (
// FileNameMinLength 规定包括后缀名在内文件名长度不可小于 5.
FileNameMinLength = 3
)
const ISO8601 = "2006-01-02T15:04:05.999+00:00"
ISO8601 需要根据服务器的具体时区来设定正确的时区
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClipText ¶
type ClipText struct { ID string // primary key Type MsgType TextMsg string FileName string `storm:"index"` FileSize int64 FileType string // MIME Checksum string `storm:"unique"` // hex(sha256) CreatedAt string `storm:"index"` // ISO8601 UpdatedAt string `storm:"index"` DeletedAt string `storm:"index"` }
ClipText 表示剪贴板文本消息,创建新的类型只是为了方便在数据库里创建一个独立的 bucket, 结构与 Message 一样。
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 Message ¶
type Message struct { ID string // primary key Type MsgType TextMsg string FileName string `storm:"index"` FileSize int64 FileType string // MIME Checksum string `storm:"unique"` // hex(sha256) CreatedAt string `storm:"index"` // ISO8601 UpdatedAt string `storm:"index"` DeletedAt string `storm:"index"` }
Message 表示一个数据表。 本来想过用 Note 来命名,但考虑到不管是熟人间互传还是个人设备间互传, 也不管互传文件还是互传文本信息,都更适合用 “消息、信息” 而不是 “笔记”。
func (*Message) SetFileNameType ¶
SetFileNameType 同时设置 FileName 和 FileType. 注意不可直接设置 FileName, 每次都应该使用 SetFileNameType 以确保同时设置 FileType.
func (*Message) SetTextMsg ¶
SetTextMsg 同时更新 TextMsg 和 FileSize, 注意不可直接设置 TextMsg, 每次都应该使用 SetTextMsg 以确保同时设置 FileSize.