Skip to content

Commit 27a1041

Browse files
authored
fix(client): cache binary path to avoid issues during self-update (#364)
Signed-off-by: Evgeniy Frolov <evgeniy.frolov@flant.com>
1 parent 6a648c5 commit 27a1041

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

client/pkg/trdl/binary.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,27 @@ import (
66
"path/filepath"
77
)
88

9-
func GetTrdlBinaryPath() (string, error) {
9+
var (
10+
trdlBinaryPath string
11+
errTrdlBinaryPath error
12+
)
13+
14+
func init() {
1015
exe, err := os.Executable()
1116
if err != nil {
12-
return "", fmt.Errorf("unable to determine trdl binary path: %w", err)
17+
errTrdlBinaryPath = fmt.Errorf("unable to determine trdl binary path: %w", err)
18+
return
1319
}
1420

1521
realExe, err := filepath.EvalSymlinks(exe)
1622
if err != nil {
17-
return "", fmt.Errorf("unable to resolve symlinks for %s: %w", exe, err)
23+
trdlBinaryPath = exe
24+
return
1825
}
1926

20-
return realExe, nil
27+
trdlBinaryPath = realExe
28+
}
29+
30+
func GetTrdlBinaryPath() (string, error) {
31+
return trdlBinaryPath, errTrdlBinaryPath
2132
}

0 commit comments

Comments
 (0)