go-repl

command module
v0.0.0-...-804b567 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 1 Imported by: 0

README

go-repl

An interactive Go REPL for the terminal. Run Go code line by line without setting up a file or opening a browser — like Python's REPL, but for Go.

Powered by Copilot CLI.

Install

From source (requires Go 1.21+):

go install github.com/TychoA/go-repl

Or clone and build locally:

git clone https://github.com/TychoA/go-repl
cd go-repl
go build -o go-repl .

Run

go-repl
go-repl version   # print version
go-repl --help    # show usage

Features

Evaluate Go expressions instantly
>> import "fmt"
>> fmt.Println("hello, world")
hello, world
Variables persist across lines
>> import "container/ring"
>> r := ring.New(5)
>> r.Value = "first"
>> import "fmt"
>> fmt.Println(r.Value)
first
Define functions with block mode

End a line with { to enter block mode. Lines are indented with .. per nesting level. The block is submitted when braces balance back to zero.

>> func greet(name string) string {
>> .. return "Hello, " + name
>> }
>> import "fmt"
>> fmt.Println(greet("Go"))
Hello, Go
Nested blocks are supported
>> func abs(n int) int {
>> .. if n < 0 {
>> .... return -n
>> .. }
>> .. return n
>> }
Compiler errors shown inline

Bad input surfaces as REPL output — your session state is not affected.

>> oops
# command-line-arguments
1:1: undefined: oops
Keyboard shortcuts
Key Action
/ Navigate input history
Esc (in block mode) Cancel the current block
Ctrl+C Exit
Built-in commands
Command Description
:reset Clear all session state
:help Show available commands
:quit / :q Exit go-repl

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
executor
Package executor builds a complete Go source file from the current session state plus new user input, runs it via `go run`, and returns the output.
Package executor builds a complete Go source file from the current session state plus new user input, runs it via `go run`, and returns the output.
history
Package history tracks the accumulated Go session state across REPL iterations.
Package history tracks the accumulated Go session state across REPL iterations.
repl
Package repl implements the interactive REPL using the Bubble Tea MVU pattern.
Package repl implements the interactive REPL using the Bubble Tea MVU pattern.

Jump to

Keyboard shortcuts

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