utils

package
v3.2.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2018 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is app version
	Version = "v3.2.5"
	// BaseURL is the base url of gost api services
	BaseURL = GetEnvOrDefault("GOSTBASEURL", "https://iuao0sjxmi.execute-api.ap-southeast-1.amazonaws.com/development/")
	// WebURL is the base url of gost web services
	WebURL = GetEnvOrDefault("GOSTWEBURL", "https://gost.zcong.moe/#/gost/")

	// MaxSize is single file max size, 30k
	MaxSize = int64(1024 * 30)
	// MaxSizeHuman is max size for human
	MaxSizeHuman = humanize.Bytes(uint64(MaxSize))
	// MaxFilesCount is max files count allowed
	MaxFilesCount = 10
	// ErrMaxFilesCount is error message for too many files
	ErrMaxFilesCount = fmt.Errorf("More than %d files is not allowed ", MaxFilesCount)
)
View Source
var ConfigFile string

ConfigFile is the true path of config file `.gostrc`

View Source
var DefaultIgnoreFiles = []string{
	".DS_Store",
}

DefaultIgnoreFiles is default ignore file name for folder sub command

View Source
var DefaultIgnoreFolders = []string{
	"node_modules",
	"vendor",
	"bin",
}

DefaultIgnoreFolders is default ignore folders name for folder sub command

Functions

func DoRequest

func DoRequest(method, url string, v interface{}, headers map[string]string) error

DoRequest do a http request and decode the json response

func Fail

func Fail(str string)

Fail log error message with colors

func GetEnvOrDefault

func GetEnvOrDefault(key, d string) string

GetEnvOrDefault return a env value or a default if not exists

func GetToken

func GetToken() string

GetToken get token from config file, env or debug token store

func Info

func Info(str string)

Info log info message with colors

func LogErrPad

func LogErrPad(err error)

LogErrPad outputs error message with color and pad

func LogPad

func LogPad(msg string)

LogPad outputs a log message with padding.

func LogSuccessPad

func LogSuccessPad(msg string)

LogErrPad outputs success message with color and pad

func Pad

func Pad() func()

Pad helper.

func ReadConfig

func ReadConfig() ([]byte, error)

ReadConfig read token from config file

func SetToken

func SetToken(tk string)

SetToken set token to debug store, only for debug

func Success

func Success(str string)

Success log success message with colors

func ToMap

func ToMap(s []string) map[string]struct{}

ToMap returns a map from slice.

func WriteConfig

func WriteConfig(token []byte) error

WriteConfig write token to config file

Types

type PathStat

type PathStat struct {
	// Error is error message
	Error error
	// IsFolder show if the PathStat is folder
	IsFolder bool
	// Size is file humanized size if is a file
	Size string
}

PathStat is file stat

func GetPathStat

func GetPathStat(p string) *PathStat

GetPathStat return the path type, if is file return file size

Jump to

Keyboard shortcuts

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