botil

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: MIT Imports: 40 Imported by: 2

README

go-botil

Documentation

Visit the docs on GoDoc

Documentation

Index

Constants

View Source
const (
	UID  = 501
	GUID = 100
)
View Source
const BriefTimeFormat = "2006-01-02"
View Source
const ServerTimeFormat = "2006-01-02T15:04:05.999Z"

Variables

View Source
var CronMinuteParser = cron.NewParser(
	cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow,
)
View Source
var EnvironmentType = []string{
	"Development",
	"Certification",
	"Production",
	"Unknown",
}
View Source
var Platform = []string{
	"ps4",
	"pc",
	"xbox",
}

Functions

func AddEnv

func AddEnv(env []string, key string, values []string) []string

func AmAdmin added in v0.1.6

func AmAdmin() bool

func CheckedScanfln

func CheckedScanfln(hint string, checkFunc CheckFunc) string

func CloseErrorStack added in v0.1.3

func CloseErrorStack()

func CloseProcess

func CloseProcess(processname string)

func Compress

func Compress(files []*os.File, dest string) error

func ConvertError added in v0.1.3

func ConvertError(err error) error

func CopyDir

func CopyDir(src string, dst string) (err error)

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist. Symlinks are ignored and skipped.

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file. The file mode will be copied from the source and the copied data is synced/flushed to stable storage.

func DeCompress

func DeCompress(zipFile, dest string) error

func DownloadFile

func DownloadFile(url string, dest string) error

func GenX509KeyPair

func GenX509KeyPair() (tls.Certificate, error)

GenX509KeyPair generates the TLS keypair for the server

func GetArrayElemWithDefault

func GetArrayElemWithDefault(array interface{}, index int, defaultValue interface{}) interface{}

func GetPathSep

func GetPathSep() byte

func GetRPC

func GetRPC(method string, id int, RPCparams ...*RPCparam) []byte

func GetRPCError

func GetRPCError(code int32, message string, id int) []byte

func GetRPCLLError

func GetRPCLLError(err error, id int) []byte

func GetRPCResult

func GetRPCResult(result interface{}, id int) []byte

func GetRPCfromJson

func GetRPCfromJson(method string, id int, params interface{}) []byte

func GetRandomID

func GetRandomID() string

func GetScanBoolFlag

func GetScanBoolFlag(printstring string, defaultbool bool) bool

func HttpJsonRespond

func HttpJsonRespond(w http.ResponseWriter, json *simplejson.Json, httpcode int, errcode int32, errmsg string)

func HttpJsonStrRespond added in v0.1.3

func HttpJsonStrRespond(w http.ResponseWriter, rootstr string, httpcode int, err error)

func HttpLLErrorRespond

func HttpLLErrorRespond(w http.ResponseWriter, httpcode int, err error)

func If

func If(condition bool, trueVal, falseVal interface{}) interface{}

func IntToInt32

func IntToInt32(num int) (res int32)

func IsErrorEqual added in v0.1.3

func IsErrorEqual(lerr error, rerr error) bool

func IsWindows

func IsWindows() bool

func ListenAndServeTLSKeyPair

func ListenAndServeTLSKeyPair(srv *http.Server, addr string, cert tls.Certificate) error

ListenAndServeTLSKeyPair start a server using in-memory TLS KeyPair

func OpenErrorStack added in v0.1.3

func OpenErrorStack()

func PrintDownloadPercent

func PrintDownloadPercent(done chan int64, path string, total int64)

func ReadLine

func ReadLine() string

func RunMeElevated added in v0.1.6

func RunMeElevated(args ...string) error

func Scanfln

func Scanfln() (string, error)

func Tar

func Tar(src string, writers ...io.Writer) error

func Untar

func Untar(dst string, r io.Reader) error

func Unzip

func Unzip(src string, dest string) ([]string, error)

func UploadDir

func UploadDir(client *sftp.Client, srcDir, desDir string) (err error)

func UploadFile

func UploadFile(client *sftp.Client, srcFilePath, desDir string) error

Types

type ApiDetail

type ApiDetail struct {
	Function    func(http.ResponseWriter, *http.Request)
	ApiPath     string
	Method      []string
	Middlewares []negroni.Handler
}

type CheckFunc

type CheckFunc func(string) bool

type Crontab added in v0.1.5

type Crontab struct {
	// contains filtered or unexported fields
}

Crontab crontab manager

func NewCrontab added in v0.1.5

func NewCrontab(mutex *sync.RWMutex, opts ...cron.Option) *Crontab

NewCrontab new crontab

func (*Crontab) AddFunc added in v0.1.5

func (c *Crontab) AddFunc(id string, spec string, f func()) error

AddByFunc add function as crontab task

func (*Crontab) AddJob added in v0.1.5

func (c *Crontab) AddJob(id string, spec string, cmd cron.Job) error

AddByID add one crontab task id is unique spec is the crontab expression

func (*Crontab) DelByID added in v0.1.5

func (c *Crontab) DelByID(id string)

DelByID remove one crontab task

func (*Crontab) GetNext added in v0.1.5

func (c *Crontab) GetNext(jid string) time.Time

func (*Crontab) IDs added in v0.1.5

func (c *Crontab) IDs() []string

IDs ...

func (*Crontab) IsExists added in v0.1.5

func (c *Crontab) IsExists(jid string) bool

IsExists check the crontab task whether existed with job id

func (*Crontab) IsValid added in v0.1.5

func (c *Crontab) IsValid(jid string) bool

func (*Crontab) Schedule added in v0.1.5

func (c *Crontab) Schedule(id string, schedule cron.Schedule, job cron.Job) error

func (*Crontab) ScheduleFunc added in v0.1.5

func (c *Crontab) ScheduleFunc(id string, schedule cron.Schedule, f func()) error

func (*Crontab) Start added in v0.1.5

func (c *Crontab) Start()

Start start the crontab engine

func (*Crontab) Stop added in v0.1.5

func (c *Crontab) Stop()

Stop stop the crontab engine

type LLError

type LLError struct {
	// contains filtered or unexported fields
}

errorString is a trivial implementation of error.

func NewError

func NewError(text string, code int32) *LLError

func (*LLError) Code

func (e *LLError) Code() int32

func (*LLError) Error

func (e *LLError) Error() string

func (*LLError) Message added in v0.1.3

func (e *LLError) Message() string

func (*LLError) Record added in v0.1.3

func (e *LLError) Record() error

type RPCparam

type RPCparam struct {
	Key   string
	Value interface{}
}

type ReadHelper

type ReadHelper struct {
	// contains filtered or unexported fields
}

func NewReadHelper

func NewReadHelper() *ReadHelper

type SFTPConnecter

type SFTPConnecter struct {
	Client       *sftp.Client
	SSHconnecter *SSHConnecter
}

func NewSFTPConnecter

func NewSFTPConnecter(user, password, host string, port int) *SFTPConnecter

func NewSFTPConnecterWithSSH

func NewSFTPConnecterWithSSH(SSHconnecter *SSHConnecter) *SFTPConnecter

func (*SFTPConnecter) Connect

func (self *SFTPConnecter) Connect() error

type SSHConnecter

type SSHConnecter struct {
	Client *ssh.Client
	// contains filtered or unexported fields
}

func NewSSHConnecter

func NewSSHConnecter(user, password, host string, port int) *SSHConnecter

func (*SSHConnecter) Connect

func (self *SSHConnecter) Connect() error

type SafeList

type SafeList struct {
	// contains filtered or unexported fields
}

func NewSafeList

func NewSafeList(mutex *sync.RWMutex) *SafeList

func (*SafeList) Front

func (sl *SafeList) Front(lock bool) *list.Element

func (*SafeList) Len

func (sl *SafeList) Len() int

func (*SafeList) PushBack

func (sl *SafeList) PushBack(lock bool, v interface{})

func (*SafeList) Remove

func (sl *SafeList) Remove(lock bool, e *list.Element)

func (*SafeList) RemoveElem

func (sl *SafeList) RemoveElem(lock bool, v interface{})

func (*SafeList) SetLock

func (sl *SafeList) SetLock(lock *sync.RWMutex)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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