

These functions return an error err satisfying errors.Is(err, ErrDot).įor example, consider these two program snippets: Instead, if the usual path algorithms would result in that answer, \go.exe on Windows, no matter how the path is configured. That is, if you run exec.LookPath("go"), it will not successfully return Using an implicit or explicit path entry relative to the current directory. To avoid those security problems, as of Go 1.19, this package will not resolve a program Is usually unexpected and often leads to security problems. Modern practice is that including the current directory Operating systems have for decades included the currentĭirectory in this search, sometimes implicitly and sometimesĬonfigured explicitly that way by default. In the directories listed in the current path, following theĬonventions of the host operating system. The functions Command and LookPath look for a program They may not run on Windows, and they do not run in the Go Playground Note that the examples in this package assume a Unix system.

To expand environment variables, use package os's ExpandEnv. Patterns, either call the shell directly, taking care to escape anyĭangerous input, or use the path/filepath package's Glob function. The packageīehaves more like C's "exec" family of functions. Pipelines, or redirections typically done by shells. Os/exec package intentionally does not invoke the system shell andĭoes not expand any glob patterns or handle other expansions, Unlike the "system" library call from C and other languages, the It wraps os.StartProcess to make itĮasier to remap stdin and stdout, connect I/O with pipes, and do other
