import "container/list" func main() { // create a new list mylist := list.New() // add elements to the list mylist.PushBack(1) mylist.PushBack(2) mylist.PushBack(3) // iterate over the list and print the values for e := mylist.Front(); e != nil; e = e.Next() { fmt.Println(e.Value) } }
import "container/list" func main() { // create a new list mylist := list.New() // add elements to the list mylist.PushBack(1) mylist.PushBack(2) mylist.PushBack(3) // remove the second element from the list toRemove := mylist.Front().Next() mylist.Remove(toRemove) // iterate over the list and print the values for e := mylist.Front(); e != nil; e = e.Next() { fmt.Println(e.Value) } }In this example, we create a new list and add three integers to it using the `PushBack` method. We then remove the second element in the list using the `Remove` method and the `Next` method to get the element to remove. Finally, we iterate over the list and print the remaining values. The `container/list` package is part of the standard library in Go.