proxy

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRunCommand

func MustRunCommand(cmd Command, opts ...RunCommandOption)

MustRunCommand is like RunCommand but panics if the command fails to build or run

func NewCommand

func NewCommand(args []string) command

NewCommand initializes a new command object and takes care of tracking the indexes of its arguments

func ProcessCommand

func ProcessCommand[T Command](cmd Command, p CommandProcessor[T]) error

ProcessCommand applies a processor on a command if said command matches the input type of said input processor. Nothing happens if the processor does not correspond to the provided command type.

func RunCommand

func RunCommand(cmd Command, opts ...RunCommandOption) error

RunCommand executes the underlying go tool command and forwards the program's standard fluxes

Types

type Command

type Command interface {
	// Close invokes all registered OnClose callbacks and releases any resources associated with the
	// command.
	Close() error

	// Args are all the command arguments, starting from the Go tool command
	Args() []string
	ReplaceParam(param string, val string) error

	// Type represents the go tool command type (compile, link, asm, etc.)
	Type() CommandType

	// ShowVersion returns true if the command received the `-V=full` argument, signaling it should
	// print its full version information and exit. This feature is used by the go toolchain to
	// create build cache keys, and allows invalidating all build cache when the tooling changes.
	ShowVersion() bool
}

Command represents a Go compilation command

func MustParseCommand

func MustParseCommand(args []string) Command

MustParseCommand calls ParseCommand and exits on error

func ParseCommand

func ParseCommand(args []string) (Command, error)

ParseCommand parses the Go tool call and its arguments and returns it as a Command. The go tool call path should be the first element of args

type CommandProcessor

type CommandProcessor[T Command] func(T) error

CommandProcessor is a function that takes a command as input and is allowed to modify it or read its data. If it returns an error, the processing chain immediately stops and no further processors will be invoked.

type CommandType

type CommandType int

CommandType represents a Go toolchain command type, such as "compile", "link", etc...

const (
	CommandTypeOther CommandType = iota
	CommandTypeCompile
	CommandTypeLink
)

type CompileCommand

type CompileCommand struct {
	Flags compileFlagSet
	Files []string
	// WorkDir is the $WORK directory managed by the go toolchain.
	WorkDir string
	// contains filtered or unexported fields
}

CompileCommand represents a go tool `compile` invocation

func (*CompileCommand) AddFiles

func (cmd *CompileCommand) AddFiles(files []string)

AddFiles adds the provided go files paths to the list of Go files passed as arguments to cmd

func (*CompileCommand) Args

func (cmd *CompileCommand) Args() []string

func (*CompileCommand) Close

func (cmd *CompileCommand) Close() error

func (*CompileCommand) GoFiles

func (cmd *CompileCommand) GoFiles() []string

GoFiles returns the list of Go files passed as arguments to cmd

func (*CompileCommand) OnClose

func (cmd *CompileCommand) OnClose(cb func() error)

OnClose registers a callback to be invoked when the command is closed, usually after it has run, unless skipping was requested by the integration.

func (*CompileCommand) ReplaceParam

func (cmd *CompileCommand) ReplaceParam(param string, val string) error

ReplaceParam will replace any parameter of the command provided it is found A parameter can be a flag, an option, a value, etc

func (*CompileCommand) ShowVersion

func (c *CompileCommand) ShowVersion() bool

func (*CompileCommand) Type

func (*CompileCommand) Type() CommandType

type LinkCommand

type LinkCommand struct {
	Flags linkFlagSet
	// WorkDir is the $WORK directory managed by the go toolchain.
	WorkDir string
	// contains filtered or unexported fields
}

LinkCommand represents a go tool `link` invocation

func (*LinkCommand) Args

func (cmd *LinkCommand) Args() []string

func (*LinkCommand) Close

func (cmd *LinkCommand) Close() error

func (*LinkCommand) OnClose

func (cmd *LinkCommand) OnClose(cb func() error)

OnClose registers a callback to be invoked when the command is closed, usually after it has run, unless skipping was requested by the integration.

func (*LinkCommand) ReplaceParam

func (cmd *LinkCommand) ReplaceParam(param string, val string) error

ReplaceParam will replace any parameter of the command provided it is found A parameter can be a flag, an option, a value, etc

func (*LinkCommand) ShowVersion

func (cmd *LinkCommand) ShowVersion() bool

func (*LinkCommand) Stage

func (cmd *LinkCommand) Stage() string

func (*LinkCommand) Type

func (*LinkCommand) Type() CommandType

type RunCommandOption

type RunCommandOption func(*exec.Cmd)

RunCommandOption allows customizing a run command before execution. For example, this can be used to capture the output of the command instead of forwarding it to the host process' STDIO.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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