summaryrefslogtreecommitdiff
path: root/submodule.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-12-01 19:11:41 -0800
committerlhchavez <[email protected]>2021-09-05 18:52:01 -0700
commit5def02a589a2c1653f4bb515fdec290361a222be (patch)
treeb99d3a8204c27c902f711bc4f8f8b48baa8352bb /submodule.go
parent70e5e419cf0cab31553b106267a0296f3cd672d9 (diff)
The big Callback type adjustment of 2020
This change makes all callbacks that can fail return an `error`. This makes things a lot more idiomatic.
Diffstat (limited to 'submodule.go')
-rw-r--r--submodule.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/submodule.go b/submodule.go
index 673cf5f..0fdaa12 100644
--- a/submodule.go
+++ b/submodule.go
@@ -8,7 +8,6 @@ extern int _go_git_visit_submodule(git_repository *repo, void *fct);
import "C"
import (
- "errors"
"runtime"
"unsafe"
)
@@ -111,7 +110,7 @@ func (c *SubmoduleCollection) Lookup(name string) (*Submodule, error) {
}
// SubmoduleCallback is a function that is called for every submodule found in SubmoduleCollection.Foreach.
-type SubmoduleCallback func(sub *Submodule, name string) int
+type SubmoduleCallback func(sub *Submodule, name string) error
type submoduleCallbackData struct {
callback SubmoduleCallback
errorTarget *error
@@ -126,9 +125,9 @@ func submoduleCallback(csub unsafe.Pointer, name *C.char, handle unsafe.Pointer)
panic("invalid submodule visitor callback")
}
- ret := data.callback(sub, C.GoString(name))
- if ret < 0 {
- *data.errorTarget = errors.New(ErrorCode(ret).String())
+ err := data.callback(sub, C.GoString(name))
+ if err != nil {
+ *data.errorTarget = err
return C.int(ErrorCodeUser)
}