util

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2023 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec added in v0.0.24

func Exec(argv0 string, argv []string, envv []string, systemCallExec SystemCallExec) error

Exec is the wrapper of syscall.Exec

func ExecCommand added in v0.0.24

func ExecCommand(context ExecContext, name string, arg ...string) *exec.Cmd

ExecCommand is a warp of exec.Command

func FakeExecCommandSuccess added in v0.0.24

func FakeExecCommandSuccess(command string, args ...string) *exec.Cmd

FakeExecCommandSuccess is a function that initialises a new exec.Cmd, one which will simply call TestShellProcessSuccess rather than the command it is provided. It will also pass through the command and its arguments as an argument to TestShellProcessSuccess

func FakeLookPath added in v0.0.24

func FakeLookPath(path string) (string, error)

FakeLookPath is a fake function of exec.LookPath

func FakeSystemCallExecSuccess added in v0.0.24

func FakeSystemCallExecSuccess(argv0 string, argv []string, envv []string) (err error)

FakeSystemCallExecSuccess is a fake function of syscall.Exec

func GeneratePassword added in v0.0.18

func GeneratePassword(length int) string

GeneratePassword generates a password with the specific length

func GetEnvOrDefault added in v0.0.31

func GetEnvOrDefault(key, defaultVal string) string

GetEnvOrDefault returns a env or default value

func InitLogger added in v0.0.23

func InitLogger(level string) (logger *zap.Logger, err error)

InitLogger returns a logger

func LookPath added in v0.0.24

func LookPath(file string, context LookPathContext) (string, error)

LookPath is the wrapper of exec.LookPath

func MaxAndMin added in v0.0.21

func MaxAndMin(data []float64) (max, min float64)

MaxAndMin return the max and min number

func Open added in v0.0.24

func Open(url string, browser string, cmdContext ExecContext) error

Open a URL in a browser

func PrintCollectTrend added in v0.0.21

func PrintCollectTrend(data []float64) (buf string)

PrintCollectTrend print the trend of data

func URLJoin added in v0.0.31

func URLJoin(host, api string) (targetURL *url.URL, err error)

URLJoin is a util function to join host URL and API URL

func URLJoinAsString added in v0.0.31

func URLJoinAsString(host, api string) (targetURLStr string, err error)

URLJoinAsString is a util function to join host URL and API URL

Types

type ExecContext added in v0.0.24

type ExecContext = func(name string, arg ...string) *exec.Cmd

ExecContext is the context of system command caller

type LookPathContext added in v0.0.24

type LookPathContext = func(file string) (string, error)

LookPathContext is the context of look path

type SystemCallExec added in v0.0.24

type SystemCallExec = func(argv0 string, argv []string, envv []string) (err error)

SystemCallExec is the context of syscall.Exec

Jump to

Keyboard shortcuts

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