MCPcopy Index your code
hub / github.com/coder/coder / portOffset

Function portOffset

scripts/develop/main.go:311–316  ·  view source on GitHub ↗

portOffset returns a deterministic offset in [0, 1000) derived from the worktree path. Successive callers with the same projectRoot get the same offset; different projectRoots get different offsets with high probability.

(projectRoot string)

Source from the content-addressed store, hash-verified

309// worktree path. Successive callers with the same projectRoot get the same
310// offset; different projectRoots get different offsets with high probability.
311func portOffset(projectRoot string) int {
312 h := fnv.New64a()
313 _, _ = h.Write([]byte(projectRoot))
314 bucket := h.Sum64() % uint64(portOffsetBuckets)
315 return int(bucket) * portOffsetStep //nolint:gosec // Bucket is less than portOffsetBuckets.
316}
317
318func (c *devConfig) applyPortOffset() {
319 c.portOffset = 0

Calls 1

WriteMethod · 0.65