If you take a look at the source code to the package you linked, it seems that the List
type holds a list of Element
s. Looking at Element
you'll see that it has one exported field called Value
which is an interface{}
type, meaning it could be literally anything: string
, int
, float64
, io.Reader
, etc.
To answer your second question, you'll see that List
has a method called Remove(e *Element)
. You can use it like this:
fmt.Println(l.Len()) // prints: 4
// Iterate through list and print its contents.
for e := l.Front(); e != nil; e = e.Next() {
if e.Value == "4" {
l.Remove(e) // remove "4"
} else {
fmt.Println(e.Value)
}
}
fmt.Println(l.Len()) // prints: 3
By and large, Golang documentation is usually pretty solid, so you should always check there first.
https://golang.org/pkg/container/list/#Element