helper

package
v3.2.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RegGoodName match a good option, argument name
	RegGoodName = `^[a-zA-Z][\w-]*$`
	// RegGoodCmdName match a good command name
	RegGoodCmdName = `^[a-zA-Z][\w-]*$`
	// RegGoodCmdId match command id. eg: "self:init"
	RegGoodCmdId = `^[a-zA-Z][\w:-]*$`
)

Variables

This section is empty.

Functions

func Download

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

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

func IsGoodCmdId added in v3.1.0

func IsGoodCmdId(name string) bool

IsGoodCmdId check

func IsGoodCmdName added in v3.1.0

func IsGoodCmdName(name string) bool

IsGoodCmdName check

func IsGoodName added in v3.1.0

func IsGoodName(name string) bool

IsGoodName check

func Panicf added in v3.1.0

func Panicf(format string, v ...any)

Panicf message

func RenderText

func RenderText(input string, data any, fns template.FuncMap, isFile ...bool) string

RenderText render text template with data. TODO use strutil.RenderText()

func SimpleDownload

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

SimpleDownload simple download

Types

type Downloader

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

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