sharlatan pushed a commit to branch go-team
in repository guix.

commit 4f27d21ac05d7ac3c990058f67c382da7bf51ca0
Author: Sharlatan Hellseher <[email protected]>
AuthorDate: Thu Jan 2 19:53:13 2025 +0000

    gnu: Add go-github-com-johncgriffin-overflow.
    
    * gnu/packages/golang-maths.scm (go-github-com-johncgriffin-overflow): New 
variable.
    
    Change-Id: I885f4eefbeaf0e41b7add3e6469a0192d2950482
---
 gnu/packages/golang-maths.scm | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/golang-maths.scm b/gnu/packages/golang-maths.scm
index 957e625cdf..b14533c169 100644
--- a/gnu/packages/golang-maths.scm
+++ b/gnu/packages/golang-maths.scm
@@ -115,6 +115,47 @@ and GCC’s decimal extension.")
      (list
       #:import-path "github.com/cockroachdb/apd/v3"))))
 
+(define-public go-github-com-johncgriffin-overflow
+  (package
+    (name "go-github-com-johncgriffin-overflow")
+    (version "0.0.0-20211019200055-46fa312c352c")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/JohnCGriffin/overflow";)
+             (commit (go-version->git-ref version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1g4sfhdmzjl5vr16lfv7nv042w8dbz608bwzyvf7xlw4i7ypjjpq"))))
+    (build-system go-build-system)
+    (arguments
+     (list
+      #:import-path "github.com/JohnCGriffin/overflow"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'generate-impl
+            ;; Note that because Go has no template types, the majority of
+            ;; repetitive code is generated by overflow_template.sh.  If you
+            ;; have to change an algorithm, change it there and regenerate the
+            ;; Go code.
+            (lambda* (#:key import-path #:allow-other-keys)
+              (with-directory-excursion (string-append "src/" import-path)
+                (substitute* "overflow_template.sh"
+                  (("/bin/sh") (which "sh")))
+                (make-file-writable "overflow_impl.go")
+                (invoke "./overflow_template.sh")
+                (invoke "go" "generate")))))))
+    (home-page "https://github.com/JohnCGriffin/overflow";)
+    (synopsis "Check for int/int64/int32 arithmetic overflow in Golang")
+    (description
+     "This package offers overflow-checked integer arithmetic operations for
+@code{int},@code{int32}, and @code{int64}.  Each of the operations returns a
+@code{result,bool} combination.  This was prompted by the need to know when to
+flow into higher precision types from the @code{math.big} library.")
+    ;; It's in README, see <https://github.com/JohnCGriffin/overflow/pull/5>.
+    (license license:expat)))
+
 (define-public go-github-com-montanaflynn-stats
   (package
     (name "go-github-com-montanaflynn-stats")

Reply via email to