本文整理匯總了Golang中github.com/gummiboll/forgetful/storage.Impl.SaveNote方法的典型用法代碼示例。如果您正苦於以下問題:Golang Impl.SaveNote方法的具體用法?Golang Impl.SaveNote怎麽用?Golang Impl.SaveNote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gummiboll/forgetful/storage.Impl
的用法示例。
在下文中一共展示了Impl.SaveNote方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AddCommand
// AddCommand adds a Note
func AddCommand(c *cli.Context, i storage.Impl) (n storage.Note, err error) {
nName, err := NoteName(c)
if err != nil {
return n, err
}
if exists := i.NoteExists(nName); exists == true {
return n, fmt.Errorf("Note already exists")
}
n.Name = nName
n.Temporary = c.Bool("t")
// Only open editor if -p (read from clipboard) isnt set
if c.IsSet("p") {
nText, err := clipboard.ReadAll()
if err != nil {
return n, err
}
n.Text = nText
} else {
if err := writer.WriteNote(&n); err != nil {
return n, err
}
}
if err := i.SaveNote(&n); err != nil {
return n, err
}
return n, nil
}
示例2: KeepCommand
// KeepCommand keeps/unkeeps a Note
func KeepCommand(c *cli.Context, i storage.Impl, k bool) (n storage.Note, err error) {
nName, err := NoteName(c)
if err != nil {
return n, err
}
n, err = i.LoadNote(nName)
if err != nil {
return n, err
}
n.Temporary = !k
if err := i.SaveNote(&n); err != nil {
return n, err
}
return n, err
}
示例3: EditCommand
// EditCommand edits a Note
func EditCommand(c *cli.Context, i storage.Impl) (n storage.Note, err error) {
nName, err := NoteName(c)
if err != nil {
return n, err
}
n, err = i.LoadNote(nName)
if err != nil {
return n, err
}
if err := writer.WriteNote(&n); err != nil {
return n, err
}
if err := i.SaveNote(&n); err != nil {
return n, err
}
return n, nil
}