utils

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Nanosecond  = int64(time.Nanosecond) // Nanosecond
	Microsecond = 1000 * Nanosecond      // Nanosecond
	Millisecond = 1000 * Microsecond     // Nanosecond
	Second      = 1000 * Millisecond     // Nanosecond
	Minute      = 60 * Second            // Nanosecond
	Hour        = 60 * Minute            // Nanosecond
	Day         = 24 * Hour              // Nanosecond
	Year        = 365 * Day              // Nanosecond

	SecondsPerYear   = Year / Second   // Second
	SecondsPerDay    = Day / Second    // Second
	SecondsPerHour   = Hour / Second   // Second
	SecondsPerMinute = Minute / Second // Second

	MillisecondsPerYear   = Year / Millisecond   // Millisecond
	MillisecondsPerDay    = Day / Millisecond    // Millisecond
	MillisecondsPerHour   = Hour / Millisecond   // Millisecond
	MillisecondsPerMinute = Minute / Millisecond // Millisecond
	MillisecondsPerSecond = Second / Millisecond // Millisecond

	MicrosecondsPerYear        = Year / Microsecond        // Microsecond
	MicrosecondsPerDay         = Day / Microsecond         // Microsecond
	MicrosecondsPerHour        = Hour / Microsecond        // Microsecond
	MicrosecondsPerMinute      = Minute / Microsecond      // Microsecond
	MicrosecondsPerSecond      = Second / Microsecond      // Microsecond
	MicrosecondsPerMillisecond = Millisecond / Microsecond // Microsecond
)
View Source
const PPROF_DUMP_BACKUP_DIR = "./prof"
View Source
const PPROF_DUMP_DIR = "prof"

Variables

This section is empty.

Functions

func CopyFile added in v1.6.1

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

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. copy the file contents from src to dst.

func CpuProfiling added in v1.6.1

func CpuProfiling(s int64)

func DGetCurrentTime

func DGetCurrentTime(layout string) string

func Dump

func Dump(name string) (*os.File, error)

func Duration

func Duration(d int64) time.Duration

func Exists

func Exists(p string) bool

func FormatMemStats

func FormatMemStats(m1, m2 *runtime.MemStats) string

func FromLocalDateToSecond

func FromLocalDateToSecond(v string) int64

func FromSecondToLocalDate

func FromSecondToLocalDate(v int64) string

func FromTime2TimeInt

func FromTime2TimeInt(t time.Time) int

func FuncName

func FuncName(skip int) string

func GcStats added in v1.6.1

func GcStats() string

func GetCurrentMicrosecond

func GetCurrentMicrosecond() int64

func GetCurrentMillisecond

func GetCurrentMillisecond() int64

func GetCurrentNanosecond

func GetCurrentNanosecond() int64

func GetCurrentSecond

func GetCurrentSecond() int64

func GetCurrentTime

func GetCurrentTime() string

func GetLocalIP

func GetLocalIP() string

func GetRealIP

func GetRealIP(request *http.Request) (string, error)

func HumanSize

func HumanSize(s uint64) string

func IsEmpty

func IsEmpty(dir string) (bool, error)
func IsLink(p string) (bool, error)

func IsLocalIP

func IsLocalIP(request *http.Request) (bool, error)

IsLocalIP, 检查是否为本地 IP

func IsSameDay

func IsSameDay(t1, t2 time.Time) bool

func IsSameDayWithTimestamp

func IsSameDayWithTimestamp(d1, d2 int64) bool

func ListDir

func ListDir(dir string) ([]string, error)

func LoadJsonToObject

func LoadJsonToObject(filename string, t interface{}) error

func Marshal

func Marshal(v interface{}) ([]byte, error)

no escape html

func MemStats added in v1.6.1

func MemStats() string

func MemStats2 added in v1.6.1

func MemStats2() string

func ParseJSON

func ParseJSON(path string, v interface{}) error

func ParseMemorySize added in v1.6.1

func ParseMemorySize(size string) (uint64, error)

k, m, g

func ReviewDumpPanic

func ReviewDumpPanic(file *os.File) error

func RuntimeStats

func RuntimeStats(d time.Duration, f func(string))

get runtime stats,contained goroutine numbers,gc pause,heap objects,heap alloc and malloc

func Sleep

func Sleep(millisecond int64)

func SplitTimeInt

func SplitTimeInt(t int) (year, month, day int)

func WithRecover added in v1.6.1

func WithRecover(fn func(), errHandler func(interface{})) (err interface{})

func WriteBlock added in v1.6.1

func WriteBlock()

func WriteGoroutine added in v1.6.1

func WriteGoroutine()

func WriteHeap added in v1.6.1

func WriteHeap()

func WriteMutex added in v1.6.1

func WriteMutex()

func WriteThreadCreate added in v1.6.1

func WriteThreadCreate()

Types

type DeployFunc added in v1.6.1

type DeployFunc func([]string) string

type FindFunc added in v1.6.1

type FindFunc func(key string) (string, error)

type Helper added in v1.6.1

type Helper struct {
	Host     string
	Updater  UpdateFunc
	Finder   FindFunc
	Perfer   PerfFunc
	Stater   StatusFunc
	Deployer DeployFunc
	// contains filtered or unexported fields
}

func (*Helper) Close added in v1.6.1

func (helper *Helper) Close()

func (*Helper) Start added in v1.6.1

func (helper *Helper) Start() error

type PerfFunc added in v1.6.1

type PerfFunc func() string

type StatusFunc added in v1.6.1

type StatusFunc func() string

type UpdateFunc added in v1.6.1

type UpdateFunc func(Key, Value, Type string, Offset int64) bool

Jump to

Keyboard shortcuts

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