From be6879dec9b67698cfd07c0f3f34e64c3db284b8 Mon Sep 17 00:00:00 2001 From: Gregorio Galante Date: Fri, 15 Dec 2017 18:58:36 +0100 Subject: [PATCH] Fixed prev link for items Changed the order of updates of pointers for new items of the list to make Prev() function works property. --- list/list.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list/list.go b/list/list.go index d8a3bda..f633d57 100644 --- a/list/list.go +++ b/list/list.go @@ -31,8 +31,8 @@ func Insert(value interface{}, list *List) *List { list.head = newItem list.last = newItem } else { - list.head = newItem list.head.prev = newItem + list.head = newItem list.last.next = newItem }