August 2019
Beginner to intermediate
798 pages
17h 2m
English
The Go source file for the implementation of the linked list is called linkedList.go, and it will be presented in five parts.
The first code segment of linkedList.go is as follows:
package main
import (
"fmt"
)
type Node struct {
Value int
Next *Node
}
var root = new(Node)
In this part of the program, you define the Node structure type that will be used for the nodes of the linked list, as well as the root global variable that holds the first element of the linked list, which will be accessible everywhere in the code. Bear in mind that although using global variables is generally fine for smaller programs and example code, it might create bugs in larger programs.
The second part of linkedList.go is shown ...
Read now
Unlock full access