func (l *List) remove(n *Node) {
	n.prev.next = n.next
	n.next.prev = n.prev
	n.next = nil
	n.prev = nil
	l.length--
}
remove element in list
package list
import (
	"fmt"
)
type Node struct {
	Value      interface{}  
	next, prev *Node        
}
type List struct {
	root   Node  
	length int   
}
func New() *List {
	l := &List{}
	l.length = 0
	l.root.next = &l.root
	l.root.prev = &l.root
	return l
}
func (l *List) IsEmpty() bool {
	return l.root.next == &l.root
}
func (l *List) Length() int {
	return l.length
}
func (l *List) PushFront(elements ...interface{}) {
	for _, element := range elements {
		n := &Node{Value: element}
		n.next = l.root.next
		n.prev = &l.root
		l.root.next.prev = n
		l.root.next = n
		l.length++
	}
}
func (l *List) PushBack(elements ...interface{}) {
	for _, element := range elements {
		n := &Node{Value: element}
		n.next = &l.root      
		n.prev = l.root.prev  
		l.root.prev.next = n  
		l.root.prev = n       
		l.length++
	}
}
func (l *List) Find(element interface{}) int {
	index := 0
	p := l.root.next
	for p != &l.root && p.Value != element {
		p = p.next
		index++
	}
	if p != &l.root {
		return index
	}
	return -1
}
func (l *List) indexFrontwise(index int) *Node {
	pos := 0
	p := l.root.next
	for p != &l.root && pos < index {
		p = p.next
		pos++
	}
	if p == &l.root {
		return nil
	}
	return p
}
func (l *List) indexBackwise(index int) *Node {
	pos := 1
	p := l.root.prev
	for p != &l.root && pos < index {
		p = p.prev
		pos++
	}
	if p == &l.root {
		return nil
	}
	return p
}
func (l *List) index(index int) *Node {
	var n *Node
	if index >= 0 {
		n = l.indexFrontwise(index)
	} else {
		n = l.indexBackwise(-index)
	}
	return n
}
func (l *List) Index(index int) (interface{}, error) {
	n := l.index(index)
	if n == nil {
		return nil, fmt.Errorf("Index %d is not valid.", index)
	}
	return n.Value, nil
}