utils

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download added in v1.2.1

func Download(url, saveDir string, rename ...string) error

Download file from remote URL. from https://gist.github.com/albulescu/e61979cc852e4ee8f49c

func ExecCommand

func ExecCommand(cmdStr string, dirAndShell ...string) (string, error)

ExecCommand alias of the ShellExec

func GetScreenSize

func GetScreenSize() (w int, h int)

GetScreenSize for current console terminal

func RenderTemplate

func RenderTemplate(input string, data interface{}, isFile ...bool) string

RenderTemplate render text template with data

func ShellExec added in v1.1.2

func ShellExec(cmdStr string, dirAndShell ...string) (string, error)

ShellExec exec a CLI command by shell and return output. usage:

utils.ShellExec("ls -al")
utils.ShellExec("ls -al", "/usr/lib")
utils.ShellExec("ls -al", "/usr/lib", "/bin/zsh")

func SimpleDownload added in v1.2.1

func SimpleDownload(url, saveAs string) (err error)

SimpleDownload simple download

Types

type Downloader added in v1.2.1

type Downloader struct {
	FileURL  string
	SaveDir  string
	Filename string // save file name.
	Progress bool   // display progress info
	// contains filtered or unexported fields
}

Downloader struct definition. refer: https://gist.github.com/albulescu/e61979cc852e4ee8f49c

func (*Downloader) Download added in v1.2.1

func (d *Downloader) Download() error

Download begin

Jump to

Keyboard shortcuts

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