Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer/util.go')
-rw-r--r--vendor/gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer/util.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/vendor/gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer/util.go b/vendor/gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer/util.go
new file mode 100644
index 000000000..c21297783
--- /dev/null
+++ b/vendor/gopkg.in/DataDog/dd-trace-go.v1/ddtrace/tracer/util.go
@@ -0,0 +1,50 @@
+package tracer
+
+import (
+ "strconv"
+ "strings"
+)
+
+// toFloat64 attempts to convert value into a float64. If it succeeds it returns
+// the value and true, otherwise 0 and false.
+func toFloat64(value interface{}) (f float64, ok bool) {
+ switch i := value.(type) {
+ case byte:
+ return float64(i), true
+ case float32:
+ return float64(i), true
+ case float64:
+ return i, true
+ case int:
+ return float64(i), true
+ case int16:
+ return float64(i), true
+ case int32:
+ return float64(i), true
+ case int64:
+ return float64(i), true
+ case uint:
+ return float64(i), true
+ case uint16:
+ return float64(i), true
+ case uint32:
+ return float64(i), true
+ case uint64:
+ return float64(i), true
+ default:
+ return 0, false
+ }
+}
+
+// parseUint64 parses a uint64 from either an unsigned 64 bit base-10 string
+// or a signed 64 bit base-10 string representing an unsigned integer
+func parseUint64(str string) (uint64, error) {
+ if strings.HasPrefix(str, "-") {
+ id, err := strconv.ParseInt(str, 10, 64)
+ if err != nil {
+ return 0, err
+ }
+ return uint64(id), nil
+ }
+ return strconv.ParseUint(str, 10, 64)
+}