{"modulePath":"github.com/memcode-ai/memcode","version":"v0.56.16","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package filelock\n\nPackage filelock is a cross-process advisory lock on a file: flock(2) on unix, LockFileEx on Windows. The OS drops the lock when the holder exits or is killed, so a crashed process never leaves it stuck. Acquire waits, but only as long as its context allows: a hung holder costs a bounded wait and a clear error, never a frozen memcode.\n\nIt exists for credential refresh: OAuth refresh tokens are single-use and rotate, so the read→refresh→write-back of a login must not interleave across processes (two memcode sessions, or memcode and the vendor's own CLI when it honors the same convention).\n\n## Functions\n\n```go\nfunc Path(name string) string\n```\nPath is the lock file for a named resource under the memcode state home (statedir.Home()/locks/\\\u003cname\u003e.lock) — never inside another tool's directory.\n\n## Types\n\n```go\ntype Lock struct {\n\t// contains filtered or unexported fields\n}\n```\nLock is a held lock. Release it exactly once (extra calls are no-ops).\n\n```go\nfunc Acquire(ctx context.Context, path string) (*Lock, error)\n```\nAcquire takes an exclusive lock on path, creating the file (and its directory) when missing. It blocks until the lock is free or ctx is done; a ctx expiry returns an error wrapping ctx.Err().\n\n```go\nfunc AcquireNamed(ctx context.Context, name string, timeout time.Duration) (*Lock, error)\n```\nAcquireNamed is Acquire on Path(name), bounded by timeout as well as ctx.\n\n```go\nfunc (l *Lock) Release() error\n```\nRelease drops the lock. Closing the descriptor releases it too, which is also what the OS does when the process dies.\n\n","path":"github.com/memcode-ai/memcode/internal/filelock","name":"filelock","synopsis":"Package filelock is a cross-process advisory lock on a file: flock(2) on unix, LockFileEx on Windows.","isRedistributable":true}
