Make WrappableCommand input be a func (#4590)
When wrapper.Wrap was put into place, the argument going into it was no longer part of a closure but was instead evaluated at function call time. As a result this would create 197 extra goroutines and channels on startup - one for each command using wrapper.Wrap. Among other things this made stack traces much more difficult to parse.
This commit is contained in:
1 parent
51d33f3393
commit
446b790f02
2 files changed
+790
-593
No files matched your search
+788
-591
File diff suppressed because it is too large.
Load diff
@@ -42,10 +42,10 @@ type CommandWrapper struct {
|
||||
}
|
||||
|
||||
// Wrap returns a cli.CommandFactory that returns a command wrapped in the CommandWrapper.
|
||||
func Wrap(c WrappableCommand) cli.CommandFactory {
|
||||
func Wrap(c func() WrappableCommand) cli.CommandFactory {
|
||||
return func() (cli.Command, error) {
|
||||
return &CommandWrapper{
|
||||
WrappableCommand: c,
|
||||
WrappableCommand: c(),
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user