コード例 #1
0
ファイル: bookmarks.go プロジェクト: jabbahotep/surf
// Read returns the URL for the bookmark with the given name.
//
// Returns an error when a bookmark does not exist with the given name. Use the
// Has() method first to avoid errors.
func (b *MemoryBookmarks) Read(name string) (string, error) {
	if !b.Has(name) {
		return "", errors.New(
			"A bookmark does not exist with the name '%s'.", name)
	}
	return b.bookmarks[name], nil
}
コード例 #2
0
ファイル: bookmarks.go プロジェクト: jabbahotep/surf
// Save saves a bookmark with the given name.
//
// Returns an error when a bookmark with the given name already exists. Use the
// Has() or Remove() methods first to avoid errors.
func (b *MemoryBookmarks) Save(name, url string) error {
	if b.Has(name) {
		return errors.New(
			"Bookmark with the name '%s' already exists.", name)
	}
	b.bookmarks[name] = url
	return nil
}
コード例 #3
0
ファイル: bookmarks.go プロジェクト: jabbahotep/surf
// Save saves a bookmark with the given name.
//
// Returns an error when a bookmark with the given name already exists. Use the
// Has() or Remove() methods first to avoid errors.
func (b *FileBookmarks) Save(name, url string) error {
	if b.Has(name) {
		return errors.New(
			"Bookmark with the name '%s' already exists.", name)
	}
	b.bookmarks[name] = url
	return b.writeToFile()
}