> # If we just got to the goal node, build and return the path.
if adjacent == goal_node:
return build_path(goal_node)
If you want to ensure the path is optimal, you'll have to wait until you 'expand' the goal node, as there might exist goal states in the open set with lower costs.
In order to catch up with language, I also decided to write a Graph library in Go[1]. Since this seems to be a quite common application, is there any more mature, bigger project implementing these same ideas? A similar concept in the Python community is python-graph[2].