August 2019
Beginner to intermediate
798 pages
17h 2m
English
It is now time to look at the implementation of a stack in Go. This will be illustrated in the stack.go source file. Once again, a linked list will be used for implementing the stack. As you know, you will need two functions: one function named Push() for putting things on the stack and another one named Pop() for removing things from the stack.
Although it is not necessary, it is useful to keep the number of elements that you have on the stack on a separate variable in order to be able to tell whether you are dealing with an empty stack or not, without having to access the linked list itself.
The source code of stack.go will be presented in four parts. The first part is as follows:
package main import ( "fmt" ) ...
Read now
Unlock full access