From d2a20e0d9659b3fbdfd6593c01067dafd61cf157 Mon Sep 17 00:00:00 2001 Message-ID: From: "Artyom V. Poptsov" Date: Sat, 2 Mar 2024 23:25:06 +0300 Subject: [PATCH 1/2] gnu: Add go-github-com-hashicorp-errwrap. * gnu/packages/golang-xyz.scm (go-github-com-hashicorp-errwrap): New variable. Change-Id: I4a0e7c23f9aaab4e29c81a68d976dafcd86dd2d1 --- gnu/packages/golang-xyz.scm | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gnu/packages/golang-xyz.scm b/gnu/packages/golang-xyz.scm index e68948e495..b52753c9bb 100644 --- a/gnu/packages/golang-xyz.scm +++ b/gnu/packages/golang-xyz.scm @@ -686,6 +686,44 @@ (define-public go-github-com-gabriel-vasile-mimetype @end itemize") (license license:expat))) +(define-public go-github-com-hashicorp-errwrap + (package + (name "go-github-com-hashicorp-errwrap") + (version "1.1.0") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/hashicorp/errwrap") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0p5wdz8p7dmwphmb33gwhy3iwci5k9wkfqmmfa6ay1lz0cqjwp7a")))) + (build-system go-build-system) + (arguments + (list + #:import-path "github.com/hashicorp/errwrap")) + (home-page "https://github.com/hashicorp/errwrap") + (synopsis "Go library for wrapping and querying errors") + (description + "@code{errwrap} is a package for Go that formalizes the pattern of wrapping +errors and checking if an error contains another error. + +There is a common pattern in Go of taking a returned @code{error} value and then +wrapping it (such as with @code{fmt.Errorf}) before returning it. The problem with +this pattern is that you completely lose the original @code{error} structure. + +Arguably the correct approach is that you should make a custom structure implementing +the @code{error} interface, and have the original error as a field on that structure, +such as @url{http://golang.org/pkg/os/#PathError, this example}. This is a good +approach, but you have to know the entire chain of possible rewrapping that happens, +when you might just care about one. + +@code{errwrap} formalizes this pattern (it doesn't matter what approach you use +above) by giving a single interface for wrapping errors, checking if a specific error +is wrapped, and extracting that error.") + (license license:mpl2.0))) + (define-public go-github-com-jinzhu-copier (package (name "go-github-com-jinzhu-copier") base-commit: b6dec0108f99d75066bad15aaa124b84bb0261f3 -- 2.41.0