{"id":13393634,"url":"https://github.com/d4l3k/go-pry","last_synced_at":"2025-05-15T00:10:41.874Z","repository":{"id":28185213,"uuid":"31686893","full_name":"d4l3k/go-pry","owner":"d4l3k","description":"An interactive REPL for Go that allows you to drop into your code at any point.","archived":false,"fork":false,"pushed_at":"2023-02-21T05:42:01.000Z","size":249,"stargazers_count":3003,"open_issues_count":7,"forks_count":64,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-03-30T16:06:55.968Z","etag":null,"topics":["go","interpreter","repl"],"latest_commit_sha":null,"homepage":"https://gopry.rice.sh/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d4l3k.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-03-05T00:10:14.000Z","updated_at":"2025-03-23T18:08:50.000Z","dependencies_parsed_at":"2024-01-11T10:57:13.784Z","dependency_job_id":null,"html_url":"https://github.com/d4l3k/go-pry","commit_stats":{"total_commits":160,"total_committers":8,"mean_commits":20.0,"dds":0.09999999999999998,"last_synced_commit":"cca3eb982836f4cfbca760c1f9e422631e4b4aa3"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4l3k%2Fgo-pry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4l3k%2Fgo-pry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4l3k%2Fgo-pry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d4l3k%2Fgo-pry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d4l3k","download_url":"https://codeload.github.com/d4l3k/go-pry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517905,"owners_count":20951718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","interpreter","repl"],"created_at":"2024-07-30T17:00:57.678Z","updated_at":"2025-04-06T17:07:51.913Z","avatar_url":"https://github.com/d4l3k.png","language":"Go","funding_links":[],"categories":["Go","开源类库","Misc","Open source library","Repositories"],"sub_categories":["运行器","Runner"],"readme":"# go-pry\n\ngo-pry - an interactive REPL for Go that allows you to drop into your code at any point.\n\n![Tests](https://github.com/d4l3k/go-pry/actions/workflows/unittest.yml/badge.svg)\n[![GoDoc](https://godoc.org/github.com/d4l3k/go-pry/pry?status.svg)](https://godoc.org/github.com/d4l3k/go-pry/pry)\n\n![go-pry](https://i.imgur.com/yr1BEsK.png)\n\nExample\n\n![go-pry Animated Example](https://i.imgur.com/H8hFzPV.gif)\n![go-pry Example](https://i.imgur.com/0rmwVY7.png)\n\n\n\n## Usage\n\nInstall go-pry\n```bash\ngo get github.com/d4l3k/go-pry\ngo install -i github.com/d4l3k/go-pry\n\n```\n\nAdd the pry statement to the code\n```go\npackage main\n\nimport \"github.com/d4l3k/go-pry/pry\"\n\nfunc main() {\n  a := 1\n  pry.Pry()\n}\n```\n\nRun the code as you would normally with the `go` command. go-pry is just a wrapper.\n```bash\n# Run\ngo-pry run readme.go\n```\n\nIf you want completions to work properly, also install `gocode` if it\nis not installed in your system\n\n```bash\ngo get -u github.com/nsf/gocode\n```\n\n\n## How does it work?\ngo-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 `.\u003cfilename\u003e.gopry` and modifies the `\u003cfilename\u003e.go` then passes the command arguments to the standard `go` command. Once the command exits, it restores the files.\n\nIf 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.\n\n## Inspiration\n\ngo-pry is greatly inspired by [Pry REPL](http://pryrepl.org) for Ruby.\n\n## License\n\ngo-pry is licensed under the MIT license.\n\nMade by [Tristan Rice](https://fn.lc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd4l3k%2Fgo-pry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd4l3k%2Fgo-pry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd4l3k%2Fgo-pry/lists"}