snippets

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Container

type Container interface {
	Insert(Snippet) error
	Find(string) (Snippet, error)
	List() ([]string, error)
	Delete(string) error
	ListObj() ([]Snippet, error)
}

Container provides an interface for a type handling snippet storage.

func NewSnippetsContainer

func NewSnippetsContainer(t string) (Container, error)

NewSnippetsContainer creates a fresh instance of snippets container.

Allowed types (t): map

type Map

type Map struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Map is a map-based implementation of a snippet Container.

func NewMap

func NewMap() *Map

NewMap creates an instance of the snippet container relying on a map composite type.

func (*Map) Delete

func (s *Map) Delete(key string) error

Delete deletes a snippet from the container.

func (*Map) Find

func (s *Map) Find(str string) (Snippet, error)

Find searches for a snippet name in the container.

func (*Map) Insert

func (s *Map) Insert(snip Snippet) (err error)

Insert inserts a snippet to the container.

func (*Map) List

func (s *Map) List() ([]string, error)

List lists out all stored snippet names.

func (*Map) ListObj

func (s *Map) ListObj() (result []Snippet, err error)

ListObj lists out all snippets stored in the container.

type Snippet

type Snippet struct {
	Name string
	Desc string
	Body string
}

Snippet carries information about a single code snippet.

func (Snippet) Repr

func (s Snippet) Repr() string

Repr provides an in-file snippet text representation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL