utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddContentOrCreateFile added in v1.0.2

func AddContentOrCreateFile(
	logger log.Logger,
	osProxy OsProxy,
	filePath string,
	blockSuffix string,
	content string,
) error

func AllEnvs added in v1.0.2

func AllEnvs() map[string]string

func ReadFileIfExists

func ReadFileIfExists(pth string) (string, bool, error)

Types

type Command added in v1.0.2

type Command interface {
	Start() error
	Wait() error
	Err() error
	CombinedOutput() ([]byte, error)
	SetStdout(file *os.File)
	SetStderr(file *os.File)
	SetStdin(file *os.File)
	SetSysProcAttr(sysProcAttr *syscall.SysProcAttr)
	PID() int
}

type CommandFunc added in v1.0.2

type CommandFunc func(ctx context.Context, command string, args ...string) Command

func DefaultCommandFunc added in v1.0.2

func DefaultCommandFunc() CommandFunc

type CommandWrapper added in v1.0.2

type CommandWrapper struct {
	Wrapped *exec.Cmd
}

func (CommandWrapper) CombinedOutput added in v1.0.2

func (cmd CommandWrapper) CombinedOutput() ([]byte, error)

func (CommandWrapper) Err added in v1.0.2

func (cmd CommandWrapper) Err() error

func (CommandWrapper) PID added in v1.0.2

func (cmd CommandWrapper) PID() int

func (CommandWrapper) SetStderr added in v1.0.2

func (cmd CommandWrapper) SetStderr(file *os.File)

func (CommandWrapper) SetStdin added in v1.0.2

func (cmd CommandWrapper) SetStdin(file *os.File)

func (CommandWrapper) SetStdout added in v1.0.2

func (cmd CommandWrapper) SetStdout(file *os.File)

func (CommandWrapper) SetSysProcAttr added in v1.0.2

func (cmd CommandWrapper) SetSysProcAttr(sysProcAttr *syscall.SysProcAttr)

func (CommandWrapper) Start added in v1.0.2

func (cmd CommandWrapper) Start() error

func (CommandWrapper) Wait added in v1.0.2

func (cmd CommandWrapper) Wait() error

type Decoder added in v1.0.2

type Decoder interface {
	Decode(data any) error
}

type DecoderFactory added in v1.0.2

type DecoderFactory interface {
	Decoder(r io.Reader) Decoder
}

type DefaultDecoderFactory added in v1.0.2

type DefaultDecoderFactory struct{}

func (DefaultDecoderFactory) Decoder added in v1.0.2

func (factory DefaultDecoderFactory) Decoder(r io.Reader) Decoder

type DefaultEncoderFactory added in v1.0.2

type DefaultEncoderFactory struct{}

func (DefaultEncoderFactory) Encoder added in v1.0.2

func (factory DefaultEncoderFactory) Encoder(w io.Writer) Encoder

type DefaultOsProxy

type DefaultOsProxy struct{}

func (DefaultOsProxy) Create added in v1.0.2

func (d DefaultOsProxy) Create(name string) (*os.File, error)

func (DefaultOsProxy) Executable added in v1.0.2

func (d DefaultOsProxy) Executable() (string, error)

func (DefaultOsProxy) FindProcess added in v1.0.2

func (d DefaultOsProxy) FindProcess(pid int) (*os.Process, error)

func (DefaultOsProxy) Getwd added in v1.0.2

func (d DefaultOsProxy) Getwd() (string, error)

func (DefaultOsProxy) Hostname added in v1.0.2

func (d DefaultOsProxy) Hostname() (string, error)

func (DefaultOsProxy) MkdirAll added in v1.0.2

func (d DefaultOsProxy) MkdirAll(pth string, perm os.FileMode) error

func (DefaultOsProxy) OpenFile added in v1.0.2

func (d DefaultOsProxy) OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

func (DefaultOsProxy) ReadFileIfExists added in v1.0.2

func (d DefaultOsProxy) ReadFileIfExists(pth string) (string, bool, error)

func (DefaultOsProxy) Remove added in v1.0.2

func (d DefaultOsProxy) Remove(name string) error

func (DefaultOsProxy) Stat added in v1.0.2

func (d DefaultOsProxy) Stat(name string) (os.FileInfo, error)

func (DefaultOsProxy) TempDir added in v1.0.2

func (d DefaultOsProxy) TempDir() string

func (DefaultOsProxy) UserHomeDir added in v1.0.2

func (d DefaultOsProxy) UserHomeDir() (string, error)

func (DefaultOsProxy) WriteFile added in v1.0.2

func (d DefaultOsProxy) WriteFile(name string, data []byte, perm os.FileMode) error

type Encoder added in v1.0.2

type Encoder interface {
	SetIndent(prefix, indent string)
	SetEscapeHTML(escape bool)
	Encode(data any) error
}

type EncoderFactory added in v1.0.2

type EncoderFactory interface {
	Encoder(w io.Writer) Encoder
}

type OsProxy

type OsProxy interface {
	Create(name string) (*os.File, error)
	Executable() (string, error)
	FindProcess(pid int) (*os.Process, error)
	Getwd() (string, error)
	Hostname() (string, error)
	MkdirAll(name string, mode os.FileMode) error
	OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)
	ReadFileIfExists(name string) (string, bool, error)
	Remove(name string) error
	Stat(pth string) (os.FileInfo, error)
	TempDir() string
	UserHomeDir() (string, error)
	WriteFile(name string, data []byte, mode os.FileMode) error
}

type TemplateProxy

type TemplateProxy struct {
	Parse   func(name string, templateText string) (*template.Template, error)
	Execute func(*template.Template, *bytes.Buffer, interface{}) error
}

func DefaultTemplateProxy

func DefaultTemplateProxy() TemplateProxy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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