How gutslike/shell-in-go works
Purpose and Entry Point
This is a minimal, cross-platform interactive command-line shell implemented in Go. Its sole executable entry point is [main.go](main.go); module and Go-version dependencies are defined in [go.mod](go.mod).
Interactive REPL Loop
[main.go](main.go) owns the shell lifecycle: display a prompt, read a user command, interpret it, execute it, and repeat until exit terminates the process. There is no server, UI framework, or persistent application state.
Command Input and Dispatch
Input is treated as a command plus arguments and dispatched through a builtin-versus-external boundary in [main.go](main.go). The current command model is intentionally simple; quoted parsing, expansions, redirection, pipelines, and job control are planned but not present architectural stages yet.
Builtin Command Layer
[main.go](main.go) implements shell-native commands:
• echo writes supplied arguments.
• exit ends the REPL/process.
• type reports whether a command is builtin or resolves to an executable.
Builtins run inside the shell process, rather than being delegated to the operating system.
External Process Resolution and Execution
For non-builtin commands, [main.go](main.go) searches directories in the host PATH environment variable, then launches the resolved executable as a child process. On Windows, resolution additionally depends on PATHEXT executable extensions; Linux and macOS/Unix use normal executable paths.
Runtime and OS Boundary
The runtime is Go 1.24+ as declared/managed through [go.mod](go.mod). The principal external dependencies are the local terminal for standard input/output, the host environment (PATH, and Windows PATHEXT), and operating-system process execution facilities. No databases, network services, containers, or cloud infrastructure are indicated.
Evolution Boundary
The repository deliberately keeps all behavior in [main.go](main.go) while shell semantics are being learned incrementally. Future features—working-directory mutation, parsing quotes, redirection, pipes, expansion, history, completion, and job control—will require separating parsing, command resolution, execution, and interactive-state management into dedicated packages or files.
Main entry points: main.go Command dispatch · go.mod go.mod
Components 11
Go Shell
- main.go · Owns the complete interactive shell lifecycle.
main.go - Prompt and input · Displays a prompt and reads one command line.
main.go - Command dispatch · Splits command input and selects builtin or external handling.
main.go - Builtins · Implements echo, exit, and type in the shell process.
main.go - Executable resolution · Searches PATH; Windows also uses PATHEXT.
main.go - Child process execution · Launches resolved non-builtin commands.
main.go - go.mod · Declares Go 1.24+ module requirements.
go.mod
Host Runtime
- Local terminal
- Host environment
- Operating system
- Go runtime
Connections 13
- Go runtime → main.go: runs
- go.mod → Go runtime: declares version
- Local terminal → Prompt and input: command input
- main.go → Prompt and input: REPL loop
- Prompt and input → Command dispatch: command line
- Command dispatch → Builtins: builtin
- Command dispatch → Executable resolution: external command
- Builtins → Local terminal: output
- Executable resolution → Host environment: reads
- Executable resolution → Child process execution: resolved executable
- Child process execution → Operating system: creates child process
- Child process execution → Local terminal: inherits I/O
- Builtins → main.go: exit terminates