Documentation ¶
Index ¶
- func CalcPadding(length, blkSize int) int
- func Checksum(srcs ...common.RawBytes) uint16
- func CreateParentDirs(file string) error
- func FillPadding(b common.RawBytes, length, blkSize int) int
- func FmtDuration(dur time.Duration) string
- func LowerKeys(m map[string]string)
- func PaddedLen(length, blkSize int) int
- func ParseDuration(durationStr string) (time.Duration, error)
- func RunsInDocker() (bool, error)
- func SecsToCompact(t uint32) string
- func SecsToTime(t uint32) time.Time
- func TimeToCompact(t time.Time) string
- func TimeToSecs(t time.Time) uint32
- func TimeToString(t time.Time) string
- func WriteFile(filename string, data []byte, perm os.FileMode) error
- type ASList
- type B64Bytes
- type ChannelLock
- type DurWrap
- type FileMode
- type Raw
- type Trigger
- type UnixTime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcPadding ¶
CalcPadding returns the number of padding bytes needed to round length bytes to a multiple of blkSize
func Checksum ¶
Calculate RFC1071 checksum of supplied data chunks. If a chunk has an odd length, it is padded with a 0 during checksum computation.
func CreateParentDirs ¶ added in v0.4.0
CreateParentDir creates the necessary parent directories for file.
func FmtDuration ¶
func LowerKeys ¶ added in v0.4.0
LowerKeys lowers all keys in the map and deletes the previous keys.
func ParseDuration ¶
ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.
It is similar to time.ParseDuration, but differs in the following ways: - It adds support for the following units: "y", "w", "d" - It requires a unit suffix - It does not support mixed unit durations (e.g. `1h10m10s` is not supported). - It does not support negative durations.
func RunsInDocker ¶ added in v0.4.0
RunsInDocker returns whether the current binary is run in a docker container.
func SecsToCompact ¶ added in v0.4.0
SecsToCompact creates a compact string representation from the seconds.
func TimeToCompact ¶ added in v0.4.0
TimeToCompact formats the time as a compat string, e.g. it discards the milliseconds parts if the time only has second resolution.
func TimeToSecs ¶ added in v0.2.0
TimeToSecs returns seconds stored as uint32.
func TimeToString ¶
TimeToString formats the time as a string.
Types ¶
type ASList ¶
func LoadASList ¶
LoadASList parses the yaml file fileName and returns a structure with non-core and core ASes.
type ChannelLock ¶
type ChannelLock struct {
// contains filtered or unexported fields
}
ChannelLock implements a sync.Mutex-like API that uses a 1-value channel behind the scenes. This makes it usable in selects that also need to meet context deadlines.
func NewChannelLock ¶
func NewChannelLock() *ChannelLock
func (*ChannelLock) Lock ¶
func (l *ChannelLock) Lock() <-chan struct{}
Lock returns a channel that can be drained to acquire the lock.
func (*ChannelLock) Unlock ¶
func (l *ChannelLock) Unlock()
type DurWrap ¶ added in v0.4.0
DurWrap is a wrapper to enable marshalling and unmarshalling of durations with the custom format.
func (DurWrap) MarshalText ¶ added in v0.4.0
func (*DurWrap) UnmarshalText ¶ added in v0.4.0
type FileMode ¶ added in v0.4.0
func (*FileMode) UnmarshalText ¶ added in v0.4.0
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
Trigger represents a timer with delayed arming. Once Arm is called, the channel return by Done() will be closed after d time. If d is 0, the channel is never closed.
func NewTrigger ¶
type UnixTime ¶ added in v0.4.0
UnixTime allows parsing and packing timestamps in seconds since epoch.
func (UnixTime) MarshalJSON ¶ added in v0.4.0
MarshalJSON marshals the time as seconds since unix epoch. This must be a value receiver.