All Projects → d4l3k → Go Pry

d4l3k / Go Pry

Licence: mit
An interactive REPL for Go that allows you to drop into your code at any point.

Programming Languages

go
31211 projects - #10 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to Go Pry

Mond
A scripting language for .NET Core
Stars: ✭ 237 (-91.37%)
Mutual labels:  interpreter, repl
Mico
Mico ("Monkey" in catalan). Monkey language implementation done with C++. https://interpreterbook.com/
Stars: ✭ 19 (-99.31%)
Mutual labels:  interpreter, repl
Ok
An open-source interpreter for the K5 programming language.
Stars: ✭ 408 (-85.15%)
Mutual labels:  interpreter, repl
retro12
This repo is retired. See http://forthworks.com:8000/
Stars: ✭ 18 (-99.34%)
Mutual labels:  interpreter, repl
Brain
An esoteric programming language compiler on top of LLVM based on Brainfuck
Stars: ✭ 112 (-95.92%)
Mutual labels:  interpreter, repl
Rascal
The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
Stars: ✭ 284 (-89.66%)
Mutual labels:  interpreter, repl
Bic
A C interpreter and API explorer.
Stars: ✭ 719 (-73.83%)
Mutual labels:  interpreter, repl
lambda
lambda calculus interpreter
Stars: ✭ 23 (-99.16%)
Mutual labels:  interpreter, repl
Endbasic
BASIC environment with a REPL, a web interface, and RPi support written in Rust
Stars: ✭ 106 (-96.14%)
Mutual labels:  interpreter, repl
Goto
Goto is an interpreted programming language written in go.
Stars: ✭ 79 (-97.12%)
Mutual labels:  interpreter, repl
lambda-dti
Interpreter of the ITGL with dynamic type inference
Stars: ✭ 18 (-99.34%)
Mutual labels:  interpreter, repl
Janet
A dynamic language and bytecode vm
Stars: ✭ 2,216 (-19.33%)
Mutual labels:  interpreter, repl
malluscript
A simple,gentle,humble scripting language for mallus, based on malayalam memes.
Stars: ✭ 112 (-95.92%)
Mutual labels:  interpreter, repl
Codi.vim
📔 The interactive scratchpad for hackers.
Stars: ✭ 2,464 (-10.3%)
Mutual labels:  interpreter, repl
huginn
Programming language with no quirks, so simple every child can master it.
Stars: ✭ 41 (-98.51%)
Mutual labels:  interpreter, repl
Red
Red is a next-generation programming language strongly inspired by Rebol, but with a broader field of usage thanks to its native-code compiler, from system programming to high-level scripting and cross-platform reactive GUI, while providing modern support for concurrency, all in a zero-install, zero-config, single 1MB file!
Stars: ✭ 4,725 (+72.01%)
Mutual labels:  interpreter, repl
klisp
A Lisp written in about 200 lines of Ink, featuring an interactive literate programming notebook
Stars: ✭ 28 (-98.98%)
Mutual labels:  interpreter, repl
ol
Otus Lisp (Ol in short) is a purely* functional dialect of Lisp.
Stars: ✭ 157 (-94.28%)
Mutual labels:  interpreter, repl
Mappy
A functional programming language. Like LISP but focused around maps rather than lists.
Stars: ✭ 10 (-99.64%)
Mutual labels:  interpreter, repl
Gomacro
Interactive Go interpreter and debugger with REPL, Eval, generics and Lisp-like macros
Stars: ✭ 1,784 (-35.06%)
Mutual labels:  interpreter, repl

go-pry

go-pry - an interactive REPL for Go that allows you to drop into your code at any point.

Tests GoDoc

go-pry

Example

go-pry Animated Example go-pry Example

Usage

Install go-pry

go get github.com/d4l3k/go-pry
go install -i github.com/d4l3k/go-pry

Add the pry statement to the code

package main

import "github.com/d4l3k/go-pry/pry"

func main() {
  a := 1
  pry.Pry()
}

Run the code as you would normally with the go command. go-pry is just a wrapper.

# Run
go-pry run readme.go

If you want completions to work properly, also install gocode if it is not installed in your system

go get -u github.com/nsf/gocode

How does it work?

go-pry is built using a combination of meta programming as well as a massive amount of reflection. When you invoke the go-pry command it looks at the Go files in the mentioned directories (or the current in cases such as go-pry build) and processes them. Since Go is a compiled language there's no way to dynamically get in scope variables, and even if there was, unused imports would be automatically removed for optimization purposes. Thus, go-pry has to find every instance of pry.Pry() and inject a large blob of code that contains references to all in scope variables and functions as well as those of the imported packages. When doing this it makes a copy of your file to .<filename>.gopry and modifies the <filename>.go then passes the command arguments to the standard go command. Once the command exits, it restores the files.

If the program unexpectedly fails there is a custom command go-pry restore [files] that will move the files back. An alternative is to just remove the pry.Apply(...) line.

Inspiration

go-pry is greatly inspired by Pry REPL for Ruby.

License

go-pry is licensed under the MIT license.

Made by Tristan Rice.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].