summaryrefslogtreecommitdiffstats
path: root/lazy/init.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-17 22:03:27 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-17 22:03:27 +0100
commitb80853de90b10171155b8f3fde47d64ec7bfa0dd (patch)
tree435d3dbf7a495a0c6ce64c9769e037179aa0d27b /lazy/init.go
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'lazy/init.go')
-rw-r--r--lazy/init.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/lazy/init.go b/lazy/init.go
index fc64b2a7d..48e9e2489 100644
--- a/lazy/init.go
+++ b/lazy/init.go
@@ -38,13 +38,13 @@ type Init struct {
children []*Init
init onceMore
- out interface{}
+ out any
err error
- f func() (interface{}, error)
+ f func() (any, error)
}
// Add adds a func as a new child dependency.
-func (ini *Init) Add(initFn func() (interface{}, error)) *Init {
+func (ini *Init) Add(initFn func() (any, error)) *Init {
if ini == nil {
ini = New()
}
@@ -58,15 +58,15 @@ func (ini *Init) InitCount() int {
}
// AddWithTimeout is same as Add, but with a timeout that aborts initialization.
-func (ini *Init) AddWithTimeout(timeout time.Duration, f func(ctx context.Context) (interface{}, error)) *Init {
- return ini.Add(func() (interface{}, error) {
+func (ini *Init) AddWithTimeout(timeout time.Duration, f func(ctx context.Context) (any, error)) *Init {
+ return ini.Add(func() (any, error) {
return ini.withTimeout(timeout, f)
})
}
// Branch creates a new dependency branch based on an existing and adds
// the given dependency as a child.
-func (ini *Init) Branch(initFn func() (interface{}, error)) *Init {
+func (ini *Init) Branch(initFn func() (any, error)) *Init {
if ini == nil {
ini = New()
}
@@ -74,14 +74,14 @@ func (ini *Init) Branch(initFn func() (interface{}, error)) *Init {
}
// BranchdWithTimeout is same as Branch, but with a timeout.
-func (ini *Init) BranchWithTimeout(timeout time.Duration, f func(ctx context.Context) (interface{}, error)) *Init {
- return ini.Branch(func() (interface{}, error) {
+func (ini *Init) BranchWithTimeout(timeout time.Duration, f func(ctx context.Context) (any, error)) *Init {
+ return ini.Branch(func() (any, error) {
return ini.withTimeout(timeout, f)
})
}
// Do initializes the entire dependency graph.
-func (ini *Init) Do() (interface{}, error) {
+func (ini *Init) Do() (any, error) {
if ini == nil {
panic("init is nil")
}
@@ -154,7 +154,7 @@ func (ini *Init) Reset() {
}
}
-func (ini *Init) add(branch bool, initFn func() (interface{}, error)) *Init {
+func (ini *Init) add(branch bool, initFn func() (any, error)) *Init {
ini.mu.Lock()
defer ini.mu.Unlock()
@@ -179,7 +179,7 @@ func (ini *Init) checkDone() {
}
}
-func (ini *Init) withTimeout(timeout time.Duration, f func(ctx context.Context) (interface{}, error)) (interface{}, error) {
+func (ini *Init) withTimeout(timeout time.Duration, f func(ctx context.Context) (any, error)) (any, error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
c := make(chan verr, 1)
@@ -203,6 +203,6 @@ func (ini *Init) withTimeout(timeout time.Duration, f func(ctx context.Context)
}
type verr struct {
- v interface{}
+ v any
err error
}