| 1 |
// Copyright 2026 The Go Authors. All rights reserved. |
| 2 |
// Use of this source code is governed by a BSD-style |
| 3 |
// license that can be found in the LICENSE file. |
| 4 |
|
| 5 |
package exec |
| 6 |
|
| 7 |
// LookPath searches for an executable named file in the current path, |
| 8 |
// following the conventions of the host operating system. |
| 9 |
// If file contains a slash, it is tried directly and the default path is not consulted. |
| 10 |
// Otherwise, on success the result is an absolute path. |
| 11 |
// |
| 12 |
// LookPath returns an error satisfying [errors.Is](err, [ErrDot]) |
| 13 |
// if the resolved path is relative to the current directory. |
| 14 |
// See the package documentation for more details. |
| 15 |
// |
| 16 |
// LookPath looks for an executable named file in the |
| 17 |
// directories named by the PATH environment variable, |
| 18 |
// except as described below. |
| 19 |
// |
| 20 |
// - On Windows, the file must have an extension named by |
| 21 |
// the PATHEXT environment variable. |
| 22 |
// When PATHEXT is unset, the file must have |
| 23 |
// a ".com", ".exe", ".bat", or ".cmd" extension. |
| 24 |
// - On Plan 9, LookPath consults the path environment variable. |
| 25 |
// If file begins with "/", "#", "./", or "../", it is tried |
| 26 |
// directly and the path is not consulted. |
| 27 |
// - On Wasm, LookPath always returns an error. |
| 28 |
func LookPath(file string) (string, error) { |
| 29 |
return lookPath(file) |
| 30 |
} |