Search steps constantly ask "is this cell even on the map?" Today you add an in-bounds check to the grid and fold it into walkable, so a step off any edge is rejected cleanly.
Add an InBounds test and make walkable respect the edges as well as walls.
You already have a Coord to name a cell and a wall flag. The gap is the
edge of the map: a coordinate like (-1, 0) or (3, 0) on a 3 by 3 grid names no
real cell at all, and indexing the wall slice with it would be wrong or crash.
The work today is bounds. A search repeatedly looks at a cell’s neighbors,
and near an edge some of those neighbors fall off the grid. Rather than guard for
that everywhere, we make it part of Walkable: a coordinate is walkable only if it
is in bounds and not a wall. That one predicate now safely answers “can the
search step here?” for any coordinate at all, on the map or not.
func (g *Grid) InBounds(c Coord) bool {return c.X >= 0 && c.Y >= 0 && c.X < g.W && c.Y < g.H}// Walkable now: in bounds AND not a wallfunc (g *Grid) Walkable(c Coord) bool {return g.InBounds(c) && !g.Wall(c)}