portmap

package
v0.36.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 3 Imported by: 0

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 Lookup

func Lookup(dir string) (int, bool)

Lookup returns the port previously recorded for dir, and whether one exists.

func Save

func Save(dir string, port int) error

Save records that dir serves on port, replacing any previous entry.

func SuggestStart

func SuggestStart(dir string, base int) int

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL