Standard library / os/exec
os/exec.ErrDot
Indicates lookup found an executable through a relative PATH entry. Treat this as a safety signal; explicitly use a trusted absolute path instead of ignoring it. Example intended for Linux/AMD64 with Go 1.23.2 in a disposable working directory; other platforms may differ. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
var ErrDot errorWorking Example
Example Snippetgo
package main
import ( "errors" "fmt" "os" "os/exec" "path/filepath")
func must(e error) { if e != nil { panic(e) }}func temp() *os.File { f, e := os.CreateTemp(".", "fixture-"); must(e); return f }func main() { f := temp() defer os.Remove(f.Name()) defer f.Close() must(f.Chmod(0700)) must(os.Setenv("PATH", ".")) _, e := exec.LookPath(filepath.Base(f.Name())) fmt.Println(errors.Is(e, exec.ErrDot))}