aboutsummaryrefslogtreecommitdiff
path: root/internal/intconv/i64_u64.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/intconv/i64_u64.go')
-rw-r--r--internal/intconv/i64_u64.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/internal/intconv/i64_u64.go b/internal/intconv/i64_u64.go
new file mode 100644
index 00000000..4c9b56c5
--- /dev/null
+++ b/internal/intconv/i64_u64.go
@@ -0,0 +1,12 @@
+package intconv
+
+import "fmt"
+
+// Int64ToUint64 converts v to uint64, returning an error if v is negative.
+func Int64ToUint64(v int64) (uint64, error) {
+ if v < 0 {
+ return 0, fmt.Errorf("intconv: int64 %d is negative", v)
+ }
+
+ return uint64(v), nil
+}