search

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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