system

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: Apache-2.0, MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildInfo

type BuildInfo interface {
	// Read reads the build info from the given path.
	Read(path string) (*buildinfo.BuildInfo, error)
}

BuildInfo is the interface for reading build info.

func NewBuildInfo

func NewBuildInfo() BuildInfo

NewBuildInfo creates a new build info.

type CleanupFunc

type CleanupFunc func() error

CleanupFunc is a function that cleans up a resource.

type Environment

type Environment interface {
	Get(key string) (string, bool)
	UserHomeDir() (string, error)
}

Environment is the interface for the environment.

func NewEnvironment

func NewEnvironment() Environment

NewEnvironment creates a new Environment.

type Exec

type Exec interface {
	Run(ctx context.Context, name string, args ...string) ExecRun
	CombinedOutput(ctx context.Context, name string, args ...string) ExecCombinedOutput
}

Exec is the interface for creating commands to be executed.

func NewExec

func NewExec() Exec

NewExec creates a new Exec.

type ExecCombinedOutput

type ExecCombinedOutput interface {
	CombinedOutput() ([]byte, error)
}

ExecCombinedOutput is an interface that represents a command that can be run and returns the combined output.

func NewExecCombinedOutput

func NewExecCombinedOutput(
	ctx context.Context,
	name string,
	args ...string,
) ExecCombinedOutput

NewExecCombinedOutput creates a new ExecCombinedOutput that runs a command. It uses the exec package to run the command, injecting the environment variables from the current process.

type ExecRun

type ExecRun interface {
	Run() error
	InjectEnv(env ...string)
}

ExecRun is an interface that represents a command that can be run and inject environment variables.

func NewExecRun

func NewExecRun(
	ctx context.Context,
	name string,
	args ...string,
) ExecRun

NewExecRun creates a new ExecRun that runs a command. It uses the exec package to run the command, injecting the environment variables from the current process.

type FileSystem

type FileSystem interface {
	// CreateDir creates a directory with the given path and permissions.
	CreateDir(path string, perm os.FileMode) error
	// CreateTempDir creates a temporary directory with the given path and pattern.
	CreateTempDir(dir, pattern string) (string, CleanupFunc, error)
	// IsSymlinkToDir checks if a path is a symlink to another directory.
	IsSymlinkToDir(path string, baseDir string) (bool, error)
	// ListBinaries lists the binaries in a directory.
	ListBinaries(path string) ([]string, error)
	// LocateBinaryInPath locates a binary in the PATH environment variable.
	LocateBinaryInPath(name string) []string
	// Move moves a file or directory.
	Move(source, target string) error
	// MoveWithSymlink moves a file and creates a symlink to the original file.
	MoveWithSymlink(source, target string) error
	// Remove removes a file or directory.
	Remove(path string) error
	// ReplaceSymlink replaces a symlink with a new source.
	ReplaceSymlink(source, target string) error
	// GetSymlinkTarget gets the target of a symlink.
	GetSymlinkTarget(path string) (string, error)
}

FileSystem is the interface for the file system.

func NewFileSystem

func NewFileSystem() FileSystem

NewFileSystem creates a new file system.

type Resource

type Resource interface {
	// Open opens a resource using the default system tools.
	Open(ctx context.Context, resource string) error
}

Resource is the interface for handling resources.

func NewResource

func NewResource(
	exec Exec,
	runtime Runtime,
) Resource

NewResource creates a new Resource.

type Runtime

type Runtime interface {
	// OS returns the operating system.
	OS() string
	// Platform returns the platform in the format "os/arch".
	Platform() string
	// Version returns the version.
	Version() string
}

Runtime is the interface for the runtime.

func NewRuntime

func NewRuntime() Runtime

NewRuntime creates a new runtime.

type Workspace

type Workspace interface {
	// GetGoBinPath returns the Go binary path.
	GetGoBinPath() string
	// GetInternalBasePath returns the internal base directory.
	GetInternalBasePath() string
	// GetInternalBinPath returns the internal binary directory.
	GetInternalBinPath() string
	// GetInternalTempPath returns the internal temporary directory.
	GetInternalTempPath() string
	// Initialize initializes the workspace.
	Initialize() error
}

Workspace is an interface that provides methods to interact with the workspace.

func NewWorkspace

func NewWorkspace(
	env Environment,
	fs FileSystem,
	runtime Runtime,
) (Workspace, error)

NewWorkspace creates a new workspace. It returns an error if the workspace initialization fails.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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