func (trie *Trie) Put(pattern string, value interface{}) error {
	if trie.Has(pattern) {
		return ErrDuplicatedPatternName
	}
	parts := trie.splitPattern(pattern)
	t := trie.Root
	for i, part := range parts {
		if node, ok := t.Children[part]; ok {
			t = node
			continue
		}
		node := NewNode(part)
		node.Value = value
		t.Children[part] = node
		if i == len(parts)-1 {
			node.patternEnding = true
		}
		t = node
	}
	return nil
}
Put add a new pattern to the trie tree.
package trie
import (
	"errors"
	"strings"
)
const (
	defalutDelimeter = "/"
)
var (
	ErrDuplicatedPatternName = errors.New("trie.go: the pattern name already exists")
)
type Trie struct {
	Delimeter string
	Root      *Node
}
func New() *Trie {
	return &Trie{
		Delimeter: defalutDelimeter,
		Root:      NewNode(),
	}
}
func (trie *Trie) SetDelimeter(delimeter string) {
	trie.Delimeter = delimeter
}
func (trie *Trie) splitPattern(pattern string) []string {
	p := strings.TrimRight(pattern, trie.Delimeter)
	parts := strings.Split(p, trie.Delimeter)
	if parts[0] == "" {
		parts[0] = string(pattern[0])
	}
	return parts
}