search

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDupItem means adding duplicated item.
	ErrDupItem = errors.New("duplicated item")
	// ErrDupSlash means item is started with more than one slash.
	ErrDupSlash = errors.New("duplicated slash")
	// ErrEmptyItem means adding empty item.
	ErrEmptyItem = errors.New("empty item")
	// ErrInvalidState means search tree is in an invalid state.
	ErrInvalidState = errors.New("search tree is in an invalid state")
	// ErrNotFromRoot means path is not starting with slash.
	ErrNotFromRoot = errors.New("path should start with /")

	// NotFound is used to hold the not found result.
	NotFound Result
)

Functions

This section is empty.

Types

type Result

type Result struct {
	Item   interface{}
	Params map[string]string
}

A Result is a search result from tree.

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

A Tree is a search tree.

func NewTree

func NewTree() *Tree

NewTree returns a Tree.

func (*Tree) Add

func (t *Tree) Add(route string, item interface{}) error

Add adds item to associate with route.

func (*Tree) Search

func (t *Tree) Search(route string) (Result, bool)

Search searches item that associates with given route.

Jump to

Keyboard shortcuts

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