diff options
Diffstat (limited to 'utilities/utilities.go')
| -rw-r--r-- | utilities/utilities.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/utilities/utilities.go b/utilities/utilities.go index 2435f1a..a441453 100644 --- a/utilities/utilities.go +++ b/utilities/utilities.go @@ -19,9 +19,15 @@ import ( "io" "math" "net/http" + "os" + "reflect" "time" ) +func IsInterfaceNil(ifc interface{}) bool { + return ifc == nil || (reflect.ValueOf(ifc).Kind() == reflect.Ptr && reflect.ValueOf(ifc).IsNil()) +} + func SignedPercentDifference(current float64, previous float64) (difference float64) { return ((current - previous) / (float64(current+previous) / 2.0)) * float64(100) } @@ -68,12 +74,7 @@ func TimedSequentialRTTs(ctx context.Context, client_a *http.Client, client_b *h return responseChannel } -type RandZeroSource struct{} - -func (RandZeroSource) Read(b []byte) (n int, err error) { - for i := range b { - b[i] = 0 - } - - return len(b), nil +func SeekForAppend(file *os.File) (err error) { + _, err = file.Seek(0, 2) + return } |
