Type semantics
Recursive types
A recursive type may refer to itself indirectly through pointers or slices. Recursion solely through array and struct types is rejected because it would require infinitely sized values. Example output: '2'.
Formal Syntax & Structure
go syntaxgo
type Node struct { Next *Node }Working Example
Example Snippetgo
package main
import "fmt"
type Node struct { Value int Next *Node}
func main() { head := Node{Value: 1, Next: &Node{Value: 2}} fmt.Println(head.Next.Value)}