Skip to content

Commit 82f306f

Browse files
committed
Resolve symlinks when looking for TINYGOROOT
On darwin, os.Executable doesn't resolve symlinks by default AFAIK, and linux does, so this normalizes the behavior to always resolve symlinks, so I can download tinygo and symlink it somewhere else. See: https://pkg.go.dev/os#Executable Signed-off-by: Tyler Rockwood <[email protected]>
1 parent 1394aca commit 82f306f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

goenv/goenv.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ func sourceDir() string {
213213
// Very unlikely. Bail out if it happens.
214214
panic("could not get executable path: " + err.Error())
215215
}
216+
resolved, err := filepath.EvalSymlinks(path)
217+
if err == nil {
218+
path = resolved
219+
}
216220
root = filepath.Dir(filepath.Dir(path))
217221
if isSourceDir(root) {
218222
return root

0 commit comments

Comments
 (0)