Documentation ¶
Overview ¶
Package util provides some additional useful functions not available in GO
Index ¶
- func Abs(n int) int
- func Abs64(n int64) int64
- func GcWithStats() string
- func Max(x, y int) int
- func Max64(x, y int64) int64
- func MemStat() string
- func Min(x, y int) int
- func Min64(x, y int64) int64
- func Nps(nodes uint64, duration time.Duration) uint64
- func ResolveCreateFolder(folderPath string) (string, error)
- func ResolveFile(file string) (string, error)
- func ResolveFolder(folder string) (string, error)
- func TimeTrack(start time.Time, name string)
- type Bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GcWithStats ¶
func GcWithStats() string
GcWithStats performs a forced garbage collection measuring duration and pre- and post-memory statistics.
func MemStat ¶
func MemStat() string
MemStat returns a string with information about the applications memory usage and GC activity
func Nps ¶
Nps calculates nodes per second from an uint64 and a duration allows zero duration by adding one nanosecond
func ResolveCreateFolder ¶
ResolveCreateFolder is resolving a path to a folder and try to find the folder in a specific set of places. If no folder can be found it will try to create a folder from the last part of the given folder path in the working directory. If a folder can't be created in the working directory it will be created in the os's temp directory. The order will be check like this:
- if path is absolute it will test if the folder exists or try to create the folder there
- if path is not absolute we will try finding the folder relative to working directory. If not found we try to create the folder there
- last we create the folder in temp
func ResolveFile ¶
ResolveFile is resolving a path to a file and try to find the file in a specific set of places and then will return an absolute path to it. Path needs to be a file or a not found error will be returned. The order will be check like this:
- if path is absolute it will return a os specific path and an error if the file does not exist
- if path is not absolute we will try first
- relative to working directory
- relative to executable
- relative to user home directory
func ResolveFolder ¶
ResolveFolder is resolving a path to a folder and try to find the folder in a specific set of places and then will return an absolute path to it. Path needs to be a folder or a not found error will be returned. The folder will not be created. The order will be check like this:
- if path is absolute it will return a os specific path and an error if the file does not exist
- if path is not absolute we will try first
- relative to working directory
- relative to executable
- relative to user home directory