Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Topological Sort

Ordering a dependency graph so nothing is built before what it needs, demoing the p/moul/x/daily/toposort library.

A graph with a cycle

auth <- session
server <- auth
session <- auth

Sort returns an error: toposort: graph has a cycle

Ordered before giving up: nothing

Stuck on the cycle: auth, server, session

The nodes still stuck are named rather than silently dropped, so a caller can report exactly which dependencies are tangled.