August 2019
Beginner to intermediate
798 pages
17h 2m
English
This subsection will illustrate the operation of the container/list package using the Go code of conList.go, which will be presented in three parts.
The first part of conList.go contains the following Go code:
package main
import (
"container/list"
"fmt"
"strconv"
)
func printList(l *list.List) {
for t := l.Back(); t != nil; t = t.Prev() {
fmt.Print(t.Value, " ")
}
fmt.Println()
for t := l.Front(); t != nil; t = t.Next() {
fmt.Print(t.Value, " ")
}
fmt.Println()
}
Here, you see a function named printList(), which allows you to print the contents of a list.List variable passed as a pointer. The Go code shows you how to print the elements of list.List starting ...
Read now
Unlock full access