From c16402d15b42cf494774796e606aba66c90d3d6b Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 6 Jan 2026 15:57:00 -0800 Subject: os/exec: move platform-specific LookPath docs to a common comment We have four different LookPath variations (unix, windows, plan9, wasm), each with slightly different doc comments. Unify the documentation and move it to a single, common LookPath. Change-Id: I56bae57e80887a73ef0f6933258ee0a48dbccdcf Reviewed-on: https://go-review.googlesource.com/c/go/+/734320 Reviewed-by: Roland Shoemaker Reviewed-by: Brad Fitzpatrick LUCI-TryBot-Result: Go LUCI --- src/os/exec/lookpath.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/os/exec/lookpath.go (limited to 'src/os/exec/lookpath.go') 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) +} -- cgit v1.3