Help us shape the future of Go! Take the 2026 Go Developer Survey

oplockcmd

package
v1.4.13 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package oplockcmd binds the project operation lock to a cobra command.

Purpose: keep internal/oplock free of cobra and the command registry. The invocation decorator (cmd/commands/invocation.go) wraps every command body with Wrap; Wrap decides, from the command's registry entry, whether the body runs under the lock.

Inputs: an entry lookup (the decorator's registry resolver, a variable in tests) and the original RunE.

Outputs: a RunE that takes the lock through oplock.Guard before the body, stores the Lock in the command context (oplock.FromContext, for early release) and releases it by defer on every return and panic.

Constraints:

  • A lock is taken only inside a project (config.FindNSelfRoot of cwd) and only for a command with a registry entry; the registry is not consulted outside a project, so a run there pays no canon parse.
  • The class is the registry class after flag escalation: a given flag only raises the side effect and replaces the output kind (EPIC D5/D6).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Effective

func Effective(cmd *cobra.Command, e *cmdregistry.Command) (side, out string)

Effective returns the side effect and output kind of e after the flags given on cmd: a flag only escalates the side effect and replaces the output kind.

func Wrap

func Wrap(entry EntryFunc, orig func(*cobra.Command, []string) error) func(*cobra.Command, []string) error

Wrap returns orig run under the project operation lock policy.

Types

type EntryFunc

type EntryFunc func(*cobra.Command) (*cmdregistry.Command, error)

EntryFunc resolves the registry entry of a command.

Jump to

Keyboard shortcuts

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