Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Find executable (which where)

  • which

  • where

  • exec

  • LookPath

  • Unix: which

  • Windows: where

  • Go:

package main

import (
	"fmt"
	"os"
	"os/exec"
)

func main() {
	path, err := exec.LookPath("python")
	if err != nil {
		fmt.Println("Could not find path")
		os.Exit(1)
	}
	fmt.Printf("%v %T\n", path, path)
}
/home/gabor/venv3/bin/python string