Documentation ¶
Index ¶
- Constants
- func Exec(argv0 string, argv []string, envv []string, systemCallExec SystemCallExec) error
- func ExecCommand(context ExecContext, name string, arg ...string) *exec.Cmd
- func FakeExecCommandSuccess(command string, args ...string) *exec.Cmd
- func FakeLookPath(path string) (string, error)
- func FakeSystemCallExecSuccess(argv0 string, argv []string, envv []string) (err error)
- func GeneratePassword(length int) string
- func InitLogger(level string) (logger *zap.Logger, err error)
- func Lenf(han string) (l int)
- func LookPath(file string, context LookPathContext) (string, error)
- func MaxAndMin(data []float64) (max, min float64)
- func Open(url string, browser string, cmdContext ExecContext) error
- func Pad(s, pad string, width int, align int) string
- func PadCenter(s, pad string, width int) string
- func PadLeft(s, pad string, width int) string
- func PadRight(s, pad string, width int) string
- func PrintCollectTrend(data []float64) (buf string)
- func ReflectFieldValueAsString(v reflect.Value, field string) string
- func SetProxy(proxy, proxyAuth string, tr *http.Transport) (err error)
- type ExecContext
- type HTTPDownloader
- type LookPathContext
- type ProgressIndicator
- type SystemCallExec
- type Table
Constants ¶
const ( // ContentType is for the http header of content type ContentType = "Content-Type" // ApplicationForm is for the form submit ApplicationForm = "application/x-www-form-urlencoded" )
const ( // AlignLeft align left AlignLeft = 0 // AlignCenter align center AlignCenter = 1 // AlignRight align right AlignRight = 2 )
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
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
FakeLookPath is a fake function of exec.LookPath
func FakeSystemCallExecSuccess ¶ added in v0.0.24
FakeSystemCallExecSuccess is a fake function of syscall.Exec
func GeneratePassword ¶ added in v0.0.18
GeneratePassword generates a password with the specific length
func InitLogger ¶ added in v0.0.23
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 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
PrintCollectTrend print the trend of data
func ReflectFieldValueAsString ¶ added in v0.0.24
ReflectFieldValueAsString returns the value of a field
Types ¶
type ExecContext ¶ added in v0.0.24
ExecContext is the context of system command caller
type HTTPDownloader ¶ added in v0.0.18
type HTTPDownloader struct { TargetFilePath string URL string ShowProgress bool InsecureSkipVerify bool UserName string Password string Proxy string ProxyAuth string Debug bool RoundTripper http.RoundTripper }
HTTPDownloader is the downloader for http request
func (*HTTPDownloader) DownloadFile ¶ added in v0.0.18
func (h *HTTPDownloader) DownloadFile() error
DownloadFile download a file with the progress
type LookPathContext ¶ added in v0.0.24
LookPathContext is the context of look path
type ProgressIndicator ¶ added in v0.0.18
type ProgressIndicator struct { Writer io.Writer Reader io.Reader Title string // bytes.Buffer Total float64 // contains filtered or unexported fields }
ProgressIndicator hold the progress of io operation
func (*ProgressIndicator) Init ¶ added in v0.0.18
func (i *ProgressIndicator) Init()
Init set the default value for progress indicator
type SystemCallExec ¶ added in v0.0.24
SystemCallExec is the context of syscall.Exec
type Table ¶
type Table struct { Out io.Writer Rows [][]string ColumnWidths []int ColumnAlign []int Separator string WithHeader bool }
Table for console print
func CreateTableWithHeader ¶ added in v0.0.23
CreateTableWithHeader init a table object
func (*Table) GetColumnAlign ¶
GetColumnAlign return the column alignment
func (*Table) SetColumnAlign ¶
SetColumnAlign sets the column alignment for the given column index
func (*Table) SetColumnsAligns ¶
SetColumnsAligns sets the alignment of the columns