Golang container/list.List.PushFront() function example
package container/list
PushFront inserts a new element e with value at the front of list l and returns the new element.
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
alist.PushFront("a")
alist.PushFront("b")
alist.PushFront("c")
alist.PushFront("d")
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
d
c
b
a
Reference :
Advertisement
Something interesting
Tutorials
+15.2k Golang : How to add color to string?
+7.5k Golang : Handling Yes No Quit query input
+10.9k Golang : Sieve of Eratosthenes algorithm
+8k Findstr command the Grep equivalent for Windows
+5.8k Unix/Linux : Get reboot history or check when was the last reboot date
+11.3k Golang : Post data with url.Values{}
+10.4k Golang : cannot assign type int to value (type uint8) in range error
+9.1k Golang : Serving HTTP and Websocket from different ports in a program example
+28.7k Golang : Detect (OS) Operating System
+30.8k Golang : Download file example
+19.4k Golang : Fix cannot download, $GOPATH not set error