Documentation
¶
Overview ¶
Package portmap remembers which TCP port each project directory serves on, so starting the same project always reuses the same port instead of drifting to whatever happens to be free at the time (the server walks past a busy port, so without memory a project's port depends on start order).
The mapping is a machine-local registry at ~/.ogcode/ports.json — a JSON object of absolute-project-dir -> port, sitting beside the global config DB. It is deliberately NOT the project-local ogcode.json: an auto-assigned port is per-machine state, not shareable project configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func All ¶ added in v0.52.0
All returns every entry in the registry — project dir (canonicalized key) → port — for callers that enumerate servers rather than look one up, such as the native-messaging host's pair sweep. The map is a copy: mutating it cannot touch the registry file.
func AllIn ¶ added in v0.52.0
AllIn is All against an explicit registry path; tests use it to avoid depending on the real HOME. A missing or corrupt file reads as empty, the way loadFrom does.
func SuggestStart ¶
SuggestStart returns a starting port for a project that has no recorded port yet: base itself when no other project has claimed it, otherwise the next port above base that no other project claims. It only avoids collisions with other projects' recorded ports — actual bind availability is left to the server, which walks past a transiently busy port on its own.
Types ¶
This section is empty.