osxec

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2026 License: MIT

README

osxec

Go Reference Go Report Card GitHub go.mod Go version Release

Golang toolkit for robust, object-oriented execution and management of OS shell commands with context support, output handling, and error management.

Features

  • Simple API for executing shell commands in OOP style
  • Pass command arguments and environment variables
  • Synchronous and asynchronous execution with context.Context support
  • Capture and process stdout/stderr output
  • Retrieve and handle process exit codes
  • Robust error handling for command execution
  • Minimal dependencies, cross-platform (works on all Go-supported OSes)
  • Clean, extensible interfaces for integration into other projects

Installation

go get github.com/sitnikovik/osxec

Getting started

import (
    "context"
    "log"

    "github.com/sitnikovik/osxec/command"
    "github.com/sitnikovik/osxec/process"
    "github.com/sitnikovik/osxec/shell"
)

func main() {
    ctx := context.Background()
    res := process.
        NewProcess(
            shell.NewShell(),
            command.NewCommand("echo", "Hello, World!"),
        ).
        Execution(ctx)
    if err := res.Err(); err != nil {
        log.Fatalf("Process execution failed: %v", err)
        return
    }
    log.Printf("Process output as string: '%s'\n", res.String())
}

Documentation

Full API reference is available on pkg.go.dev

Requirements

  • Go 1.23.4 (as declared in go.mod) — newer Go versions should work
  • No external runtime dependencies

Contributing

Contributions are welcome. Suggested workflow:

  1. Pick an open issue and work on it. Open a Pull Request that references the issue when you're ready
  2. If there is no suitable issue for your idea, either open a short issue describing the proposal or contact me (watch my bio) and we will create an issue for you.
  3. Fork the repository and create a feature branch: git checkout -b feature/name
  4. Run and add tests for new behavior: go test ./...
  5. Commit changes with a descriptive message and open a Pull Request
  6. Follow the repository's code style and linters (we use golangci-lint)
  7. If the PR passes, we merge it and create version via GitHub releases

Please open an issue to discuss large or breaking changes before implementing.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Author / Contact

Maintained by Ilya Sitnikov

Directories

Path Synopsis
Package command provides structures and functions to create and manage system commands.
Package command provides structures and functions to create and manage system commands.
output
Package output provides structures and functions to handle command output.
Package output provides structures and functions to handle command output.
internal
test/fake
Package fake provides fake implementations for testing purposes.
Package fake provides fake implementations for testing purposes.
test/fake/shell
Package shell provides fake implementations of shell-related interfaces for testing purposes.
Package shell provides fake implementations of shell-related interfaces for testing purposes.
Package process provides types and functions for managing system processes.
Package process provides types and functions for managing system processes.
execution
Package execution provides types and functions for handling process execution results.
Package execution provides types and functions for handling process execution results.
exit/code
Package code provides types and functions for handling process exit codes.
Package code provides types and functions for handling process exit codes.
Package shell provides utilities for working with shell commands and scripts.
Package shell provides utilities for working with shell commands and scripts.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL