add iterate example for glist; improve variable name for ghttp.Server

This commit is contained in:
John
2019-12-18 19:44:40 +08:00
parent ae0fa888f0
commit df99036d41

View File

@ -63,6 +63,20 @@ func Example_iterate() {
fmt.Println()
// iterate reading from head using IteratorAsc.
l.IteratorAsc(func(e *glist.Element) bool {
fmt.Print(e.Value)
return true
})
fmt.Println()
// iterate reading from head using IteratorDesc.
l.IteratorDesc(func(e *glist.Element) bool {
fmt.Print(e.Value)
return true
})
fmt.Println()
// iterate writing from head.
l.LockFunc(func(list *list.List) {
length := list.Len()
@ -80,5 +94,7 @@ func Example_iterate() {
//output:
//12345678910
//10987654321
//12345678910
//10987654321
//[1,2,3,4,5,"M",7,8,9,10]
}