Files
llgo/_demo/oslookpath/lookpath.go
2024-07-11 19:21:04 +08:00

20 lines
216 B
Go

package main
import (
"fmt"
"os/exec"
"runtime"
)
func main() {
ls := "ls"
if runtime.GOOS == "windows" {
ls = "dir"
}
lspath, _ := exec.LookPath(ls)
if lspath != "" {
ls = lspath
}
fmt.Println(ls)
}