diff options
| author | Carlos Amedee <carlos@golang.org> | 2026-01-21 15:45:40 -0500 |
|---|---|---|
| committer | Carlos Amedee <carlos@golang.org> | 2026-01-21 15:56:01 -0500 |
| commit | eec3c0ca956803db8a90dfd92ce4ebffebdaf9b4 (patch) | |
| tree | 14ed37a5aa0fd9e80b547fd43086b2b137457726 /src/os/exec/lookpath.go | |
| parent | 4606a931d2b099f2c5e5619b797352607ee42225 (diff) | |
| parent | 2baa1d17628bb2f09757617382b1e61f1f9f0ddd (diff) | |
| download | go-eec3c0ca956803db8a90dfd92ce4ebffebdaf9b4.tar.xz | |
[release-branch.go1.26] all: merge master (2baa1d1) into release-branch.go1.26
For #76474.
Change-Id: Ic50e288f99b731b62af9aa73ce6721f0f2f3596d
Diffstat (limited to 'src/os/exec/lookpath.go')
| -rw-r--r-- | src/os/exec/lookpath.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/os/exec/lookpath.go b/src/os/exec/lookpath.go new file mode 100644 index 0000000000..71f86b994f --- /dev/null +++ b/src/os/exec/lookpath.go @@ -0,0 +1,30 @@ +// Copyright 2026 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package exec + +// LookPath searches for an executable named file in the current path, +// following the conventions of the host operating system. +// If file contains a slash, it is tried directly and the default path is not consulted. +// Otherwise, on success the result is an absolute path. +// +// LookPath returns an error satisfying [errors.Is](err, [ErrDot]) +// if the resolved path is relative to the current directory. +// See the package documentation for more details. +// +// LookPath looks for an executable named file in the +// directories named by the PATH environment variable, +// except as described below. +// +// - On Windows, the file must have an extension named by +// the PATHEXT environment variable. +// When PATHEXT is unset, the file must have +// a ".com", ".exe", ".bat", or ".cmd" extension. +// - On Plan 9, LookPath consults the path environment variable. +// If file begins with "/", "#", "./", or "../", it is tried +// directly and the path is not consulted. +// - On Wasm, LookPath always returns an error. +func LookPath(file string) (string, error) { + return lookPath(file) +} |
