Golang container/list.List.PushBack() function example
package container/list
PushBack inserts a new element e with value at the back of list l and returns the new element.
Golang container/list.List.PushBack() function usage example
package main
import (
"container/list"
"fmt"
)
func main() {
alist := list.New()
alist.PushBack("a")
alist.PushBack("b")
alist.PushBack("c")
alist.PushBack("d")
for e := alist.Front(); e != nil; e = e.Next() {
fmt.Println(e.Value) // print out the elements
}
}
Output :
a
b
c
d
Reference :
Advertisement
Something interesting
Tutorials
+13.9k Golang : How to determine if a year is leap year?
+20.2k Golang : Convert seconds to human readable time format example
+22.5k Golang : Convert Unix timestamp to UTC timestamp
+8.5k Golang : How to check variable or object type during runtime?
+27.9k Golang : Decode/unmarshal unknown JSON data type with map[string]interface
+10.3k Golang : Wait and sync.WaitGroup example
+12.4k Golang : Search and extract certain XML data example
+7.3k Golang : How to iterate a slice without using for loop?
+5.8k Golang : List all packages and search for certain package
+26.3k Golang : Calculate future date with time.Add() function
+12.3k Golang : Display list of countries and ISO codes
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?