Skip to content

Commit 3a4be22

Browse files
committed
fix: handle nil function with tool.Stopped in dtm start module
Signed-off-by: Daniel Hu <[email protected]>
1 parent e0cb110 commit 3a4be22

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

internal/pkg/start/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func installToolsIfNotExist() error {
2424
return err
2525
}
2626
}
27-
if !t.Stopped() {
27+
if t.Stopped != nil && !t.Stopped() {
2828
if err := t.Start(); err != nil {
2929
return err
3030
}

internal/pkg/start/tool/tool.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ type stopedFunc func() bool
55
type installFunc func() error
66
type startFunc func() error
77
type tool struct {
8-
Name string
9-
Exists existsFunc
8+
Name string
9+
Exists existsFunc
10+
// Stopped can be nil if it is not needed.
11+
// if Stopped != nil -> Start can't be nil too
1012
Stopped stopedFunc
1113
Install installFunc
1214
Start startFunc

0 commit comments

Comments
 (0)