Advanced Structs Concepts

This lesson provides detailed information on structs and how other data structures are related to structs in Go.

Recursive structs

A struct type can be defined in terms of itself. This is particularly useful when the struct variable is an element of a linked list or a binary tree, commonly called a node. In that case, the node contains links (the addresses) to the neighboring nodes.

In the following examples, next for a list and left and right for a tree are pointers to another Node-variable.

Linked List

Get hands-on with 1200+ tech skills courses.