I wrote a function to find the loop in a list using golang. But I am not able to construct a loop in a list as input.
Please find below the code,
package main
import (
"container/list"
"fmt"
)
func main() {
l := list.New()
l.PushBack(0)
l.PushBack(1)
l.PushBack(2)
l.PushBack(3)
l.PushBack(4)
l.PushBack(5)
e6 := l.PushBack(6)
l.PushBack(7)
e8 :=l.PushBack(8)
e9 := l.InsertAfter(9,e8)
l.InsertBefore(e9, e6)
for e:=l.Front() ; e !=nil ; e=e.Next() {
fmt.Println(e.Value)
}
}
could anyone help me on this?