本文整理匯總了Golang中github.com/gummiboll/forgetful/storage.Impl.RenameNote方法的典型用法代碼示例。如果您正苦於以下問題:Golang Impl.RenameNote方法的具體用法?Golang Impl.RenameNote怎麽用?Golang Impl.RenameNote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gummiboll/forgetful/storage.Impl
的用法示例。
在下文中一共展示了Impl.RenameNote方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RenameCommand
// RenameCommand renames a Note
func RenameCommand(c *cli.Context, i storage.Impl) (nName string, newName string, err error) {
nName, err = NoteName(c)
if err != nil {
return nName, newName, err
}
n, err := i.LoadNote(nName)
if err != nil {
return nName, newName, err
}
reader := bufio.NewReader(os.Stdin)
fmt.Print(fmt.Sprintf("Rename note '%s' to: ", n.Name))
newName, err = reader.ReadString('\n')
if err != nil {
return nName, newName, err
}
newName = strings.Trim(newName, "\n")
if newName == "" {
return nName, newName, errors.New("Note name can't be blank")
}
if i.NoteExists(newName) == true {
return nName, newName, fmt.Errorf("Note '%s' already exists", newName)
}
if err = i.RenameNote(n.ID, newName); err != nil {
return nName, newName, fmt.Errorf("Failed to rename note '%s' to '%s'.", nName, newName)
}
return nName, newName, nil
}