utils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: BSD-3-Clause Imports: 10 Imported by: 8

Documentation

Index

Constants

View Source
const (
	K = 1024
	M = 1024 * K
	G = 1024 * M
)

Variables

View Source
var (
	LastSizeErr error
)

Functions

func DirUsage

func DirUsage(path string) (size int64, err error)

func Fnv1a

func Fnv1a(buf []byte) (h uint32)

Bugy version of fnv1a 由于历史原因,最初使用了带有 bug 的 fnv1a,现在修正的代价比较大, 涉及到数据的迁移.

func GetMaxRSS

func GetMaxRSS() int64

func GetStack

func GetStack(bytes int) string

func Getrusage

func Getrusage() syscall.Rusage

func InitSizesForValue

func InitSizesForValue(m reflect.Value) (err error)

func InitSizesPointer

func InitSizesPointer(c interface{}) (err error)

func Remove

func Remove(path string) error

func Rename

func Rename(path, newpath string) error

func SizeToStr

func SizeToStr(n int64) (s string)

func StrToSize

func StrToSize(s string) (n int64)

Types

type Dir

type Dir struct {
	Files map[string]int64
}

func NewDir

func NewDir() *Dir

func (*Dir) CheckPath

func (d *Dir) CheckPath(path string) (d2 *Dir, r1, r2 []File, err error)

func (*Dir) Delete

func (d *Dir) Delete(name string)

func (*Dir) Diff

func (d *Dir) Diff(d2 *Dir) (r1, r2 []File)

func (*Dir) Load

func (d *Dir) Load(path string) (err error)

func (*Dir) Set

func (d *Dir) Set(name string, size int64)

func (*Dir) SetMulti

func (d *Dir) SetMulti(files map[string]int64)

func (*Dir) SetMultiNoSize

func (d *Dir) SetMultiNoSize(files ...string)

func (*Dir) ToSlice

func (d *Dir) ToSlice() []File

type DiskStatus

type DiskStatus struct {
	Root    string
	All     int64
	Used    int64
	Free    int64
	Buckets []int `yaml:",flow"`
}

func DiskUsage

func DiskUsage(path string) (disk DiskStatus, err error)

type File

type File struct {
	Name string
	Size int64
}

type FileList

type FileList []File

func (FileList) Len

func (by FileList) Len() int

func (FileList) Less

func (by FileList) Less(i, j int) bool

func (FileList) Swap

func (by FileList) Swap(i, j int)

type HashMethod

type HashMethod func(v []byte) (h uint32)

Jump to

Keyboard shortcuts

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