Documentation
¶
Index ¶
- Constants
- func AnyBlank(args ...string) bool
- func Apply[T any](o *T, opts ...Option[T])
- func B64Decode(source string) []byte
- func B64Encode(src []byte) []byte
- func Blanks(args ...string) bool
- func Bytes(data string) []byte
- func DObj[T any](source, d T) T
- func DString(source, d string) string
- func ErrorArgument(err error) error
- func ErrorArgumentf(format string, v ...any) error
- func ExternalIp() (net.IP, bool)
- func FileExists(path string) bool
- func First[S ~[]E, E any](d E, list S) E
- func IntranetIp() (net.IP, bool)
- func IsBlank(b string) bool
- func IsEmail(email string) bool
- func Map[T, R any](dest []T, mapper func(T) R) (rs []R)
- func Nils(objs ...any) bool
- func NonBlank(v string) bool
- func NonBlanks(args ...string) bool
- func RandomTCPListener() (net.Listener, error)
- func SQLString(s string) sql.NullString
- func String(data []byte) string
- type Command
- func (c *Command) Dir(directory string) *Command
- func (c *Command) Env(env []string) *Command
- func (c *Command) Path(path string) *Command
- func (c *Command) Pipeout(fn func(line string)) *Command
- func (c *Command) StartAndWait() error
- func (c *Command) Stderr(stderr io.Writer) *Command
- func (c *Command) Stdin(stdin io.Reader) *Command
- func (c *Command) Stdout(stdout io.Writer) *Command
- type CommandBatch
- type CommandItem
- type Option
- func WithDir(dir string) Option[CommandBatch]
- func WithEnvs(envs []string) Option[CommandBatch]
- func WithPath(path string) Option[CommandBatch]
- func WithPipeFn(fn func(string)) Option[CommandBatch]
- func WithStderr(stderr io.Writer) Option[CommandBatch]
- func WithStdin(stdin io.Reader) Option[CommandBatch]
- func WithStdout(stdout io.Writer) Option[CommandBatch]
- type OptionFunc
- type Options
- type ResponseEntity
- type SafeRunner
Constants ¶
View Source
const TimeMillis = "15:04:05.000"
Variables ¶
This section is empty.
Functions ¶
func DObj ¶
func DObj[T any](source, d T) T
DObj returns source if not nil else return default value
func ErrorArgument ¶
func ErrorArgumentf ¶
func ExternalIp ¶
func FileExists ¶
func IntranetIp ¶
func RandomTCPListener ¶
Types ¶
type Command ¶
func (*Command) StartAndWait ¶
type CommandBatch ¶
type CommandBatch struct { Path string Dir string Env []string Stdin io.Reader Stdout io.Writer Stderr io.Writer PipeFn func(string) }
func CmdBatch ¶
func CmdBatch(opts ...Option[CommandBatch]) *CommandBatch
func (*CommandBatch) Run ¶
func (b *CommandBatch) Run(items ...CommandItem) error
type CommandItem ¶
type Option ¶
type Option[T any] interface { Apply(*T) }
func WithDir ¶
func WithDir(dir string) Option[CommandBatch]
func WithEnvs ¶
func WithEnvs(envs []string) Option[CommandBatch]
func WithPath ¶
func WithPath(path string) Option[CommandBatch]
func WithPipeFn ¶
func WithPipeFn(fn func(string)) Option[CommandBatch]
func WithStderr ¶
func WithStderr(stderr io.Writer) Option[CommandBatch]
func WithStdout ¶
func WithStdout(stdout io.Writer) Option[CommandBatch]
type OptionFunc ¶
type OptionFunc[T any] func(*T)
func (OptionFunc[T]) Apply ¶
func (f OptionFunc[T]) Apply(t *T)
type ResponseEntity ¶
type ResponseEntity interface { Code() int Error() string Marshal() ([]byte, error) MarshalIdent() ([]byte, error) }
func NewErrResponse ¶
func NewErrResponse(code int, msg string) ResponseEntity
func NewResponse ¶
func NewResponse(payload any) ResponseEntity
type SafeRunner ¶
type SafeRunner struct {
// contains filtered or unexported fields
}
func NewSafeRunner ¶
func NewSafeRunner() *SafeRunner
func (*SafeRunner) Err ¶
func (r *SafeRunner) Err() error
func (*SafeRunner) Run ¶
func (r *SafeRunner) Run(fn func() error)
Click to show internal directories.
Click to hide internal directories.