← All notes

Go os/exec: run external commands

Answer: Package exec runs external commands. Package exec runs external commands. Call Command to build the process.

Examples

package main
import (
    "fmt"
    "os/exec"
)
func main() {
    out, err := exec.Command("echo", "hello").Output()
    if err != nil {
        panic(err)
    }
    fmt.Print(string(out))
}

Rules

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Go docs, os/exec package; Go source, src/os/exec/exec.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Go docs, os/exec package; Go source, src/os/exec/exec.go. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:964sk41f

iinventedlight. 2026. "Go os/exec: run external commands." iinventedlight Library, iil:note:964sk41f, version of 2026-11-18. https://iinventedlight.com/library/notes/go-os-exec/. License: CC-BY-4.0.

@misc{iil_note_964sk41f,
  author = {{iinventedlight}},
  title = {{Go os/exec: run external commands}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-18},
  url = {https://iinventedlight.com/library/notes/go-os-exec/},
  note = {Permanent ID iil:note:964sk41f. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-os-exec.md.