Skip to content

Commit 16b393d

Browse files
author
Konikz
committed
fix: use Must() to cache executable path
This commit uses Must() to cache the executable path and makes it overridable in tests. Signed-off-by: Konikz <konikz@github.com>
1 parent d3d606a commit 16b393d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pkg/usrlocalsharelima/usrlocalsharelima.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ import (
1313

1414
"github.com/lima-vm/lima/pkg/debugutil"
1515
"github.com/lima-vm/lima/pkg/limayaml"
16+
. "github.com/lima-vm/lima/pkg/must"
1617
"github.com/sirupsen/logrus"
1718
)
1819

20+
// executable is a variable that can be overridden in tests.
21+
var executable = os.Executable
22+
1923
func Dir() (string, error) {
20-
self, err := os.Executable()
21-
if err != nil {
22-
return "", err
23-
}
24+
self := Must(executable())
2425
selfSt, err := os.Stat(self)
2526
if err != nil {
2627
return "", err

0 commit comments

Comments
 (0)