Go-based shell which works cross-platform (Linux, Windows), is interactive and intuitive to use.
- Block-Based Input: Write multi-line Go code naturally - press Enter for new lines, code executes when block is complete
- Smart Compilation: Code only added to project when it compiles successfully
- Hot Reload: Leverages yaegi interpreter for instant code execution without compilation overhead
- Workspace as Monorepo: Maintains a Go monorepo in
~/.gosh/with session code ininternal/directory - CLI Tool Generation: On exit, converts your session into a Cobra-based CLI tool
- Cross-Platform: Works seamlessly on Linux, Windows, and macOS
- Command History: Track and review your command history
- Session Persistence: All session code saved to
~/.gosh/internal/session_TIMESTAMP.go
Download the latest release from the Releases page:
- Linux:
gosh-linux-amd64 - macOS Intel:
gosh-darwin-amd64 - macOS Apple Silicon:
gosh-darwin-arm64 - Windows:
gosh-windows-amd64.exe
git clone https://github.com/Napolitain/gosh.git
cd gosh
go build -o gosh ../goshStart the shell:
./goshhelp- Show available commandshistory- Display command historyclear- Clear history and workspaceworkspace- Show workspace information (path, internal path, session ID)reload- Reload workspace codeexitorquit- Exit the shell (prompts to save as CLI tool)
Welcome to gosh - Go Shell
Write multi-line code blocks - press Enter for new lines
Press Ctrl+Enter (Cmd+Enter on Mac) to execute your code block
Type 'help' for commands, 'exit' to quit
gosh> fmt.Println("Hello, World!")
Hello, World!
✓ Code compiled and added to project
gosh> x := 42
✓ Code compiled and added to project
gosh> y := 58
✓ Code compiled and added to project
gosh> total := x + y
✓ Code compiled and added to project
gosh> fmt.Printf("Total: %d\n", total)
Total: 100
✓ Code compiled and added to project
gosh> for i := 0; i < 3; i++ {
... fmt.Printf("Iteration %d\n", i)
... }
Iteration 0
Iteration 1
Iteration 2
✓ Code compiled and added to project
gosh> history
Command history:
1 fmt.Println("Hello, World!")
2 x := 42
3 y := 58
4 total := x + y
5 fmt.Printf("Total: %d\n", total)
6 for i := 0; i < 3; i++ { fmt.Printf("Iteration %d\n", i) }
gosh> workspace
Workspace directory: /home/user/.gosh
Internal directory: /home/user/.gosh/internal
Session ID: 20251026_143022
gosh> exit
Would you like to save this session as a CLI tool? (y/n): y
Enter CLI tool name: hello_tool
✓ CLI tool 'hello_tool' generated successfully!
Location: /home/user/.gosh/cmd/hello_tool/
To build: cd /home/user/.gosh/cmd/hello_tool && go build
Exiting gosh...
gosh provides true block-based input:
- Press Enter to add new lines within your code block
- Press Ctrl+Enter (Cmd+Enter on Mac) to execute your code block
- Perfect for writing multi-line Go code naturally
- Code is compiled and executed when you complete a block
- Only on success is code added to the project workspace
- Failed compilation shows errors without corrupting your project
- Success shows "✓ Code compiled and added to project"
gosh uses the yaegi Go interpreter, which provides instant code execution without traditional compilation. This allows for:
- Immediate feedback on code execution
- Interactive development and experimentation
- Fast iteration cycles
gosh maintains a Go monorepo structure in ~/.gosh/:
~/.gosh/
├── go.mod # Module definition
├── internal/ # Session code
│ └── session_TIMESTAMP.go
└── cmd/ # Generated CLI tools
└── <tool_name>/
└── main.go
Each session creates a file in internal/ with all successfully compiled code blocks. This structure allows you to:
- Maintain a clean Go module
- Easily reference code across sessions
- Build complete applications from sessions
When exiting gosh, you can save your session as a Cobra-based CLI tool:
- Exit with
exitorquitcommand - Answer "y" when prompted to save as CLI tool
- Provide a name for your tool
- Tool is generated in
~/.gosh/cmd/<name>/ - Build with:
cd ~/.gosh/cmd/<name> && go build
The generated CLI reproduces all your session code, making it easy to share or deploy your experiments.
gosh/
├── main.go # Entry point
├── internal/
│ ├── shell/ # Shell REPL implementation
│ │ ├── shell.go # Block-based input & execution
│ │ └── shell_test.go
│ └── workspace/ # Workspace management
│ ├── workspace.go # Monorepo & CLI generation
│ └── workspace_test.go
└── ~/.gosh/ # User workspace (created at runtime)
├── go.mod # Go module definition
├── internal/ # Session code storage
│ └── session_TIMESTAMP.go
└── cmd/ # Generated CLI tools
└── <tool_name>/
└── main.go
go build -o gosh .go test ./... -v- Syntax highlighting in terminal
- Tab completion for Go keywords and functions
- Integration with external Go packages
- Import management UI
- Configuration file support
- Multi-user workspace support
See LICENSE file for details.
Contributions are welcome! Feel free to open issues or submit pull requests.