The LastNode method

The LastNode method of LinkedList returns the node at the end of the list. The list is traversed to check whether nextNode is nil from nextNode of headNode, as follows:

//LastNode method returns the last Node

func (linkedList *LinkedList) LastNode() *Node{
var node *Node
var lastNode *Node
for node = linkedList.headNode; node != nil; node = node.nextNode {
if node.nextNode ==nil {
lastNode = node
}
}
return lastNode
}