Documentation ¶
Overview ¶
various utilities
Index ¶
- Variables
- func CheckFile(fpath string) (exists bool)
- func ClientNameFromID(id []byte) (name string)
- func EnsureDir(fpath string) (err error)
- func EnsureFile(fpath string, size uint64) (err error)
- func FormatRate(rate float64) (str string)
- func RandBoolPercent(percent uint8) bool
- func RandStr(l int) string
- func Ratio(tx, rx float64) (r float64)
- func SchemePath(u *url.URL) (scheme string, path string)
- func StartedAt() time.Time
- func WriteFull(w io.Writer, d []byte) (err error)
- type Buffer
- type Rate
- func (r *Rate) AddSample(n uint64)
- func (r *Rate) BDecode(rd io.Reader) (err error)
- func (r *Rate) BEncode(w io.Writer) (err error)
- func (r *Rate) Current() (cur uint64)
- func (r *Rate) Max() (max uint64)
- func (r *Rate) Mean() float64
- func (r *Rate) Min() (min uint64)
- func (r *Rate) PrevTickTime() time.Time
- func (r *Rate) Tick()
- type RateSample
Constants ¶
This section is empty.
Variables ¶
View Source
var Discard discard
View Source
var StringCompare = strings.Compare
View Source
var Zero = new(zeroReader)
reader that reads zeros
Functions ¶
func ClientNameFromID ¶
func EnsureFile ¶
ensure a file and its parent directory exists
func FormatRate ¶
FormatRate formats a floating point b/s as string with closest unit
func RandBoolPercent ¶
Types ¶
type Rate ¶
type Rate struct { Samples []RateSample // contains filtered or unexported fields }
func (*Rate) PrevTickTime ¶
type RateSample ¶
type RateSample [2]uint64
(magnitude, time)
func (*RateSample) Add ¶
func (s *RateSample) Add(n uint64)
func (*RateSample) Clear ¶
func (s *RateSample) Clear()
func (*RateSample) Set ¶
func (s *RateSample) Set(n uint64)
func (RateSample) Time ¶
func (s RateSample) Time() time.Time
func (RateSample) Value ¶
func (s RateSample) Value() uint64
Click to show internal directories.
Click to hide internal directories.