comm

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: MIT Imports: 29 Imported by: 1

README

go_comm

Documentation

Overview

copy of github.com/go-task/task/v3/internal/execext/devnull.go

Index

Constants

This section is empty.

Variables

View Source
var TraceId atomic.Int64

Functions

func BroadcastInterfaces

func BroadcastInterfaces(dump bool) []net.Interface

func BroadcastIpWithInterface

func BroadcastIpWithInterface(intf net.Interface) net.IP

func DefaultOutput

func DefaultOutput() io.Writer

func DowncastMap added in v1.1.1

func DowncastMap[V any](m map[string]V) map[string]any

func EnvSubst

func EnvSubst(input string, env map[string]any) string

func EnvSubstSlice

func EnvSubstSlice(inputs []string, env map[string]any) []string

func EnvironList

func EnvironList(overrides map[string]any) []string

func EnvironMap

func EnvironMap(overrides map[string]any) map[string]string

func ExecZenity added in v1.4.0

func ExecZenity(ctx context.Context, hc interp.HandlerContext, args []string) error

func Executable

func Executable() string

func GoshExecHandler added in v1.4.0

func GoshExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc

func Hostname

func Hostname() string

func IsDarwin

func IsDarwin() bool

func IsTerminal

func IsTerminal() bool

func IsWindows

func IsWindows() bool

func JoinedLines

func JoinedLines(lines ...string) string

func JoinedLinesAsBytes

func JoinedLinesAsBytes(lines ...string) []byte

func Map2Struct

func Map2Struct(src map[string]any, dest any)

func Pair2Vars added in v1.2.0

func Pair2Vars(pairs []string) map[string]any

func ReadBytes

func ReadBytes(reader io.Reader) []byte

ReadBytes ...

func ReadLines

func ReadLines(reader io.Reader) []string

func ReadText

func ReadText(reader io.Reader) string

ReadText ...

func RenderAsTemplate

func RenderAsTemplate(tmpl string, data map[string]any) string

func RenderAsTemplateArray

func RenderAsTemplateArray(tmplArray []string, data map[string]any) []string

func RenderWithTemplate

func RenderWithTemplate(w io.Writer, name string, tmpl string, data map[string]any)

func ResolveBroadcastIp

func ResolveBroadcastIp(interfaces []net.Interface, interfaceName string) (localIp net.IP, broadcastIp net.IP)

func RunCommandWithInput

func RunCommandWithInput(vars map[string]any, dir string, cmd string, args ...string) func(...string) CommandOutput

func Slice2Map

func Slice2Map[V any](arr []V, keyFunc func(v V) string) map[string]V

func Slice2Set

func Slice2Set[T comparable](arr ...T) *hashset.Set

func SliceEquals

func SliceEquals[T comparable](a []T, b []T) bool

func StructToMap

func StructToMap(src any) map[string]any

func SubstVars

func SubstVars(m map[string]any, parentVars map[string]any, keysToSkip ...string) map[string]any

func Text2Lines

func Text2Lines(text string) []string

func Text2Vars added in v1.2.0

func Text2Vars(text string) map[string]any

func TextLine2Array

func TextLine2Array(line string) []string

func ToYaml

func ToYaml(hint string, me any) string

func Vars2Pair added in v1.2.0

func Vars2Pair(vars map[string]any) []string

func WorkingDirectory

func WorkingDirectory() string

func ZenityError added in v1.4.0

func ZenityError(ctx context.Context, hc interp.HandlerContext, args []string) error

func ZenityInfo added in v1.4.0

func ZenityInfo(ctx context.Context, hc interp.HandlerContext, args []string) error

func ZenityQuestion added in v1.4.0

func ZenityQuestion(ctx context.Context, hc interp.HandlerContext, args []string) error

func ZenityWarning added in v1.4.0

func ZenityWarning(ctx context.Context, hc interp.HandlerContext, args []string) error

Types

type CommandOutput added in v1.3.0

type CommandOutput = *CommandOutputT

func ParseCommandOutput added in v1.3.0

func ParseCommandOutput(outputText string) CommandOutput

func RunAdminCommand

func RunAdminCommand(vars map[string]any, adminPassword string, dir string, cmd string) CommandOutput

func RunAppleScript

func RunAppleScript(vars map[string]any, adminPassword string, dir string, script string) CommandOutput

RunApplacript 运行 applacript

func RunCommandWithoutInput

func RunCommandWithoutInput(vars map[string]any, dir string, cmd string, args ...string) CommandOutput

func RunGoShellCommand

func RunGoShellCommand(vars map[string]any, dir string, cmd string) CommandOutput

func RunShellCommand

func RunShellCommand(vars map[string]any, dir string, sh string, cmd string) CommandOutput

func RunSudoCommand

func RunSudoCommand(vars map[string]any, sudoerPassword string, dir string, command string) CommandOutput

func RunUserCommand

func RunUserCommand(vars map[string]any, dir string, cmd string) CommandOutput

type CommandOutputKind added in v1.3.0

type CommandOutputKind byte
const (
	COMMAND_OUTPUT_KIND_TEXT CommandOutputKind = iota
	COMMAND_OUTPUT_KIND_VARS
	COMMAND_OUTPUT_KIND_JSON
)

type CommandOutputT added in v1.3.0

type CommandOutputT struct {
	Kind CommandOutputKind
	Vars map[string]any
	Text string
	Json any
}

type ErrorGroup

type ErrorGroup = *ErrorGroupT

func NewErrorGroup

func NewErrorGroup(dumpStack bool) ErrorGroup

func (ErrorGroup) Add

func (me ErrorGroup) Add(err error)

func (ErrorGroup) AddGroup

func (me ErrorGroup) AddGroup(that ErrorGroup)

func (ErrorGroup) AmountOfErrors

func (me ErrorGroup) AmountOfErrors() int

func (ErrorGroup) Error

func (me ErrorGroup) Error() string

func (ErrorGroup) HasError

func (me ErrorGroup) HasError() bool

type ErrorGroupT

type ErrorGroupT struct {
	// contains filtered or unexported fields
}

type EventLogger

type EventLogger = *EventLoggerT

func NewEventLogger

func NewEventLogger(target Logger) EventLogger

func (EventLogger) LogDebug

func (me EventLogger) LogDebug(enm event.LogEnum, hub string, topic string, lsner string)

func (EventLogger) LogError

func (me EventLogger) LogError(enm event.LogEnum, hub string, topic string, lsner string, err any)

func (EventLogger) LogEventDebug

func (me EventLogger) LogEventDebug(enm event.LogEnum, lsner string, evnt event.Event)

func (EventLogger) LogEventError

func (me EventLogger) LogEventError(enm event.LogEnum, lsner string, evnt event.Event, err any)

func (EventLogger) LogEventInfo

func (me EventLogger) LogEventInfo(enm event.LogEnum, lsner string, evnt event.Event)

func (EventLogger) LogInfo

func (me EventLogger) LogInfo(enm event.LogEnum, hub string, topic string, lsner string)

func (EventLogger) Target

func (me EventLogger) Target() Logger

type EventLoggerT

type EventLoggerT struct {
	// contains filtered or unexported fields
}

type LogContext

type LogContext = LogEntry

func NewLogContext

func NewLogContext(generateNewTraceId bool) LogContext

type LogEntry

type LogEntry = *plog.Entry

type Logger

type Logger = *LoggerT

func NewDiscardLogger

func NewDiscardLogger() Logger

func NewLogger

func NewLogger(console io.Writer, config LoggerConfig, fileName string) Logger

/ verbose: log to console if true

func (Logger) Close

func (me Logger) Close()

func (Logger) Error

func (me Logger) Error(err any) LogEntry

func (Logger) NewSubLogger

func (me Logger) NewSubLogger(lctx LogContext) Logger

func (Logger) Parent

func (me Logger) Parent() Logger

type LoggerConfig

type LoggerConfig = *LoggerConfigT

type LoggerConfigT

type LoggerConfigT struct {
	MaxSize    int  `json:"max_size" yaml:"maxsize"`
	MaxAge     int  `json:"max_age" yaml:"maxage"`
	MaxBackups int  `json:"max_backups" yaml:"maxbackups"`
	LocalTime  bool `json:"local_time" yaml:"localtime"`
	Compress   bool `json:"compress" yaml:"compress"`
}

see lumberjack.Logger

type LoggerT

type LoggerT struct {
	plog.Logger
	// contains filtered or unexported fields
}

type OSType

type OSType int

OSType ...

const (
	// AllOSType ...
	AllOSType OSType = iota

	// Windows ...
	Windows

	// Darwin ...
	Darwin

	// Linux ...
	Linux
)

func BuildOSType

func BuildOSType(i int) OSType

BuildOSType ...

func DefaultOSType

func DefaultOSType() OSType

DefaultOSType ...

func ParseOSType

func ParseOSType(s string) OSType

ParseOSType ...

Directories

Path Synopsis
playground

Jump to

Keyboard shortcuts

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