Migration: go 1.18

This commit is contained in:
Dreamacro
2022-03-16 12:10:13 +08:00
parent d1dd21417b
commit 6a661bff0c
73 changed files with 705 additions and 307 deletions

View File

@ -51,7 +51,7 @@ func ValidAndSplitDomain(domain string) ([]string, bool) {
// 3. subdomain.*.example.com
// 4. .example.com
// 5. +.example.com
func (t *DomainTrie) Insert(domain string, data interface{}) error {
func (t *DomainTrie) Insert(domain string, data any) error {
parts, valid := ValidAndSplitDomain(domain)
if !valid {
return ErrInvalidDomain
@ -68,7 +68,7 @@ func (t *DomainTrie) Insert(domain string, data interface{}) error {
return nil
}
func (t *DomainTrie) insert(parts []string, data interface{}) {
func (t *DomainTrie) insert(parts []string, data any) {
node := t.root
// reverse storage domain part to save space
for i := len(parts) - 1; i >= 0; i-- {

View File

@ -3,7 +3,7 @@ package trie
// Node is the trie's node
type Node struct {
children map[string]*Node
Data interface{}
Data any
}
func (n *Node) getChild(s string) *Node {
@ -18,7 +18,7 @@ func (n *Node) addChild(s string, child *Node) {
n.children[s] = child
}
func newNode(data interface{}) *Node {
func newNode(data any) *Node {
return &Node{
Data: data,
children: map[string]*Node{},