d4l3k / go-pry Goto Github PK
View Code? Open in Web Editor NEWAn interactive REPL for Go that allows you to drop into your code at any point.
Home Page: https://gopry.rice.sh/
License: MIT License
An interactive REPL for Go that allows you to drop into your code at any point.
Home Page: https://gopry.rice.sh/
License: MIT License
Cool project. Seems like it doesn't recognize for loops, though (not sure if you expect it to work or not)
$ cat src/pry-test/main.go
package main
import "github.com/d4l3k/go-pry/pry"
func main() {
for i := 0; i < 10; i++ {
i++
pry.Pry()
}
}
$ go-pry src/pry-test/main.go
Prying into src/pry-test/main.go
[0x2082cc810]
Unknown *ast.ForStmt
integrate with https://github.com/go-rod/rod
have a project using Go 1.11 Go Module with go.mod:
#file go.mod
module just-go
require(
blah blah blah...
)
main file like this:
//file main.go
package main
import (
"fmt"
"github.com/d4l3k/go-pry/pry"
"just-go/db"
)
func main() {
fmt.Printf("%v\n", db.DB)
fmt.Println("starting debug....")
pry.Pry()
}
run pry
$ go-pry run main.go
2018/12/25 20:18:52 main.go:28: cannot find package "just-go/db" in any of:
/Users/jojo/.gvm/gos/go1.11.1/src/just-go/db (from $GOROOT)
/Users/jojo/.gvm/pkgsets/go1.11.1/global/src/just-go/db (from $GOPATH)
as i use the old way set the source path into GOPATH, got this:
$ ln -s just-go $GOPATH/src
$ go-pry run main.go
&{<nil> <nil> 0 0xc0000d2480 false 2 {0xc000185180} <nil> {{0 0} {<nil>} map[] 0} 0xc000118c60 0x17cde40 0xc0001c28a0 false}
starting debug....
panic: failed to TypeCheck: /Users/jojo/yiwu/just-go/tasks/debug/debug.go:5:2: could not import github.com/d4l3k/go-pry/pry (can't find import: "github.com/d4l3k/go-pry/pry")
goroutine 1 [running]:
github.com/d4l3k/go-pry/pry.Apply(0xc0001e8100)
/Users/jojo/.gvm/pkgsets/go1.11.1/global/pkg/mod/github.com/d4l3k/[email protected]/pry/pry.go:28 +0x220
main.main()
/Users/jojo/yiwu/just-go/main.go:12 +0x198a
exit status 2
2018/12/25 20:21:26 main.go:28: exit status 1
Go Module has a new way to put the compiled pkg into the $GOPATH/pkg/mod, and no longer use the $GOPATH/src, any other idea to fix this problem ?
Are there missing dependencies or some such in the tutorial when run from a local end point, or am I meant to change some other environment variable?
/home/arran/tmp/pry
arran@arran-yoga 10411% GOPATH=$PWD/gopath go install github.com/d4l3k/go-pry
/home/arran/tmp/pry
arran@arran-yoga 10412% cat > readme.go
package main
import "github.com/d4l3k/go-pry/pry"
func main() {
a := 1
pry.Pry()
}
/home/arran/tmp/pry
arran@arran-yoga 10413% go-pry run readme.go
zsh: command not found: go-pry
/home/arran/tmp/pry
arran@arran-yoga 10414% ./gopath/bin/go-pry run readme.go
panic: cannot find package "github.com/d4l3k/go-pry/pry" in any of:
/usr/lib/go-1.8/src/github.com/d4l3k/go-pry/pry (from $GOROOT)
/home/arran/go/src/github.com/d4l3k/go-pry/pry (from $GOPATH)
goroutine 1 [running]:
main.InjectPry(0xc420014660, 0x59, 0x6b9763, 0x3, 0x300000001, 0xc4200001a0)
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:64 +0x802
main.main.func4(0xc4200179a0, 0x45, 0x7d7160, 0xc4200fe750, 0x0, 0x0, 0x0, 0x0)
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:251 +0xdd
path/filepath.walk(0xc4200179a0, 0x45, 0x7d7160, 0xc4200fe750, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc4200196c0, 0x3d, 0x7d7160, 0xc4200fe680, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420102120, 0x2a, 0x7d7160, 0xc4200fe5b0, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42000f6e0, 0x22, 0x7d7160, 0xc4200e21a0, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42000adc0, 0x1b, 0x7d7160, 0xc4200e20d0, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42000ad20, 0x15, 0x7d7160, 0xc4200e2000, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420012f40, 0xa, 0x7d7160, 0xc42006dee0, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420012e40, 0x6, 0x7d7160, 0xc42006d110, 0xc42000efc0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0x6b95b4, 0x1, 0x7d7160, 0xc42006d040, 0xc42000efc0, 0x0, 0x30)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x6b95b4, 0x1, 0xc42000efc0, 0x0, 0x1)
/usr/lib/go-1.8/src/path/filepath/path.go:398 +0x14c
main.main()
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:259 +0x63d
/home/arran/tmp/pry
arran@arran-yoga 10415% GOPATH=$PWD/gopath ./gopath/bin/go-pry run readme.go
panic: cannot find package "golang.org/x/tools/go/gcimporter15" in any of:
/usr/lib/go-1.8/src/golang.org/x/tools/go/gcimporter15 (from $GOROOT)
/home/arran/tmp/pry/gopath/src/golang.org/x/tools/go/gcimporter15 (from $GOPATH)
goroutine 1 [running]:
main.InjectPry(0xc42032fe50, 0x46, 0x6b9763, 0x3, 0x300000001, 0xc4200001a0)
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:64 +0x802
main.main.func4(0xc42019ac80, 0x32, 0x7d7160, 0xc420c1d380, 0x0, 0x0, 0x0, 0x0)
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:251 +0xdd
path/filepath.walk(0xc42019ac80, 0x32, 0x7d7160, 0xc420c1d380, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc420262bd0, 0x26, 0x7d7160, 0xc420d33ad0, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42000f710, 0x22, 0x7d7160, 0xc4200e8270, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42000adc0, 0x1b, 0x7d7160, 0xc4200e81a0, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42000ad20, 0x15, 0x7d7160, 0xc4200e80d0, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420012f40, 0xa, 0x7d7160, 0xc4200e8000, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420012e40, 0x6, 0x7d7160, 0xc42006d1e0, 0xc42000eff0, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0x6b95b4, 0x1, 0x7d7160, 0xc42006d110, 0xc42000eff0, 0x0, 0x30)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x6b95b4, 0x1, 0xc42000eff0, 0x0, 0x1)
/usr/lib/go-1.8/src/path/filepath/path.go:398 +0x14c
main.main()
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:259 +0x63d
/home/arran/tmp/pry
arran@arran-yoga 10416% GOPATH=$PWD/gopath ./gopath/bin/go-pry run readme.go
panic: cannot find package "golang.org/x/tools/go/gcimporter15" in any of:
/usr/lib/go-1.8/src/golang.org/x/tools/go/gcimporter15 (from $GOROOT)
/home/arran/tmp/pry/gopath/src/golang.org/x/tools/go/gcimporter15 (from $GOPATH)
goroutine 1 [running]:
main.InjectPry(0xc4204c0870, 0x46, 0x6b9763, 0x3, 0x300000001, 0xc4200001a0)
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:64 +0x802
main.main.func4(0xc4204c8d80, 0x32, 0x7d7160, 0xc4204c48f0, 0x0, 0x0, 0x0, 0x0)
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:251 +0xdd
path/filepath.walk(0xc4204c8d80, 0x32, 0x7d7160, 0xc4204c48f0, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc420c501e0, 0x26, 0x7d7160, 0xc4200f7ad0, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42007b440, 0x22, 0x7d7160, 0xc4201081a0, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42007e9e0, 0x1b, 0x7d7160, 0xc4201080d0, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42007e940, 0x15, 0x7d7160, 0xc420108000, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420082cd0, 0xa, 0x7d7160, 0xc420087ee0, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420082bd0, 0x6, 0x7d7160, 0xc420087110, 0xc42007ad20, 0x0, 0x0)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0x6b95b4, 0x1, 0x7d7160, 0xc420087040, 0xc42007ad20, 0x0, 0x30)
/usr/lib/go-1.8/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x6b95b4, 0x1, 0xc42007ad20, 0x0, 0x1)
/usr/lib/go-1.8/src/path/filepath/path.go:398 +0x14c
main.main()
/home/arran/tmp/pry/gopath/src/github.com/d4l3k/go-pry/main.go:259 +0x63d
/home/arran/tmp/pry
arran@arran-yoga 10424% ls -dl gopath/src/*/*
drwxrwxr-x 3 arran arran 4096 Jul 14 13:47 gopath/src/github.com/d4l3k/
drwxrwxr-x 5 arran arran 4096 Jul 14 13:47 gopath/src/github.com/mattn/
drwxrwxr-x 3 arran arran 4096 Jul 14 13:47 gopath/src/github.com/mgutz/
drwxrwxr-x 3 arran arran 4096 Jul 14 13:47 gopath/src/github.com/pkg/
I don't know how much of the point is defeated by tying this to an IDE but can you summarize any existing plans or roadmap for IDE integration? It seems like it would be pretty involved.
hhadmin@local:~/go/src/github.com/househappy/hyper_sonic$ go get github.com/d4l3k/go-pry
# github.com/d4l3k/go-pry
../../d4l3k/go-pry/main.go:162: syntax error: unexpected range, expecting {
../../d4l3k/go-pry/main.go:167: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:168: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:169: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:180: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:181: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:182: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:189: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:191: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:196: non-declaration statement outside function body
../../d4l3k/go-pry/main.go:196: too many errors
I'm wondering if it's in the scope of go-pry to eventually allow it to run in non-main packages. The way I currently have my Go project set up is to have a main package that sources certain functionalities from a ton of subpackages.
First off: thanks so much for this project! I love pry
.
I am a bit of a newbie to golang, so it is totally possible I have set things up wrong. Here's my experience trying to use go-pry
on my project vessel (./main.go:50
is where I'm calling pry.Pry()
):
Ansible:~/Documents/Code/golang/src/vessel/ master ⌂ go-pry run main.go
# command-line-arguments
./main.go:50: undefined: parser in parser.ParseVesselMap
./main.go:50: undefined: parser in parser.VesselMapAsInts
./main.go:50: undefined: parser in parser.ParseVesselYaml
./main.go:50: undefined: viewcomponents in viewcomponents.UpdateTimer
./main.go:50: undefined: viewcomponents in viewcomponents.CleanUp
./main.go:50: undefined: viewcomponents in viewcomponents.VisorView
./main.go:50: undefined: viewcomponents in viewcomponents.VesselMap
./main.go:50: undefined: viewcomponents in viewcomponents.ChamberMenu
./main.go:50: undefined: goncurses in goncurses.Below
./main.go:50: undefined: goncurses
./main.go:50: too many errors
Reverting files
It could be an incidental effect of the log order, but it appears all of the packages failing to be imported are non-stdlib ones I'm grabbing via github.
Let me know if I can get you any other information, or feel free to point me to the general area of the code I might be able to tinker with to get a solution. Always happier to give a PR than an issue. :)
After exit the go-pry, any input into the terminal doesn't dis displays.
OS: Ubuntu 16.04
Golang: 1.8.3
It seems like there are some parsing errors
[3] go-pry> s := make([]string, 3)
Error: 1:20: illegal character U+0005 (and 1 more errors) <nil>
Sorry for not providing details. Here are what I mentioned. Wish to add some debug related commands for us to debug as python(ipdb) or ruby(pry)
5: "github.com/d4l3k/go-pry/pry"
6: )
7:
8: func main() {
9: a := 1
=> 10: pry.Pry()
11: fmt.Println("A", a)
12: }
13:
[31] go-pry> a = 2
=> 2
[32] go-pry>
I modify the var a value to 2, and willing to execute next
or continue
commands to continue the program.
Is there any methods to add those to go-pry? I have noticed what you have mentioned below it just has wrap go
commands. So i thought it is impossible to add those commands.
I'm trying to use go-pry to debug this golang project-> https://github.com/komuw/meli
But go-pry is panicking with a weird error, reproduced below:
go-pry run *.go
panic: cannot find package "foo" in any of:
/home/komu/go/src/github.com/komuw/meli/vendor/foo (vendor tree)
/usr/local/go/src/foo (from $GOROOT)
/home/komu/go/src/foo (from $GOPATH)
goroutine 1 [running]:
main.InjectPry(0xc420214c00, 0x60, 0x6c8703, 0x3, 0x1, 0xc42042f6d8)
/home/komu/go/src/github.com/d4l3k/go-pry/main.go:65 +0x14c0
main.main.func4(0xc423200740, 0x38, 0x80cde0, 0xc420231930, 0x0, 0x0, 0x0, 0x0)
/home/komu/go/src/github.com/d4l3k/go-pry/main.go:252 +0x140
path/filepath.walk(0xc423200740, 0x38, 0x80cde0, 0xc420231930, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:356 +0x81
path/filepath.walk(0xc4233a2ea0, 0x30, 0x80cde0, 0xc420231860, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.walk(0xc421eb60f0, 0x26, 0x80cde0, 0xc4221a4c30, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.walk(0xc422661e00, 0x1e, 0x80cde0, 0xc4221a4750, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.walk(0xc422661da0, 0x17, 0x80cde0, 0xc4221a4680, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.walk(0xc4205932a0, 0x11, 0x80cde0, 0xc420426dd0, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.walk(0xc420216288, 0x6, 0x80cde0, 0xc420426d00, 0xc4200ea030, 0x0, 0x0)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.walk(0x6c8554, 0x1, 0x80cde0, 0xc4200ec0d0, 0xc4200ea030, 0x0, 0x30)
/usr/local/go/src/path/filepath/path.go:381 +0x39a
path/filepath.Walk(0x6c8554, 0x1, 0xc4200ea030, 0x2, 0x3)
/usr/local/go/src/path/filepath/path.go:403 +0x11d
main.main()
/home/komu/go/src/github.com/d4l3k/go-pry/main.go:243 +0x53e
I'm using dep(https://github.com/golang/dep) as my dependency management tool
First: thanks for doing this, this it the most functional go repl out there!
While not a big issue, but it would be nice to be able to copy-paste larger code blocks into the repl directly. History + tab completion would be the cherry on top of it.
Here is a project that used the go impl. of readline with great success, maybe this could be something useful here?
https://github.com/abiosoft/ishell
Cheers
Roman
Hello,
I put a pry.Pry()
on a root handler but it yielded nothing. I was using it with Gin, FYI.
Anyone can help?
Apologies if this is already explained elsewhere, but it's not clear from the examples in the readme if it's possible to run go-pry
as a standalone REPL.
When I try I get this error, but I'm not sure if it's the normal behaviour or a problem with my setup.
$ go get github.com/d4l3k/go-pry
$ go install github.com/d4l3k/go-pry
$ which go-pry
....../go/bin/go-pry
$ go-pry -i="fmt,math,strconv"
panic: failed to TypeCheck: /var/folders/mw/hh951k897lv1c8nchgxyy9zw0000gp/T/pry101925011/main.go:3:2: could not import github.com/d4l3k/go-pry/pry (can't find import: "github.com/d4l3k/go-pry/pry")
goroutine 1 [running]:
github.com/d4l3k/go-pry/pry.Apply(0xc4200ba200)
/Users/Tom/source/go/src/github.com/d4l3k/go-pry/pry/pry.go:86 +0x228
main.main()
/var/folders/mw/hh951k897lv1c8nchgxyy9zw0000gp/T/pry101925011/main.go:9 +0x3217
exit status 2
Assign the latest value to a variable, _
for instance, so that you can build on whatever resulted in the last command without having to arrow-up and edit it.
I don't what the state of this project vs. gomacro is. However if gomacro is more powerful, it might be worth to switch the engine. If this does not make any sense, feel free to close this issue.
For example if I need to run
go test -test.run="^TestRefreshToken$"
and put, in one of the test
pry.Pry()
I have followed the instructions and done all the necessary installation. However I got "go-pry: command not found" when I was trying to run the command go-pry run main.go
I am wondering if I am missing something? Thanks
Hey, I tried to use go-pry
in a project where external packages are below vendor/
. Go pry keeps saying packages not found:
panic: cannot find package "github.com/google/go-github/github" in any of:
/usr/local/go/src/github.com/google/go-github/github (from $GOROOT)
/src/github.com/google/go-github/github (from $GOPATH)
it's actually in /src//vendor/github.com/google/go-github/github
Could you give me some pointers how to fix this pls?
Hello. Fetching the project fails for me running:
go get "github.com/d4l3k/go-pry/pry"
with:
package golang.org/x/tools/go/gcimporter: cannot find package "golang.org/x/tools/go/gcimporter" in any of:
/usr/local/go/src/golang.org/x/tools/go/gcimporter (from $GOROOT)
/home/vagrant/go/src/golang.org/x/tools/go/gcimporter (from $GOPATH)
However, /home/vagrant/go/src/golang.org/x/tools/go
has gcimporter15
directory
Symlinking gcimporter15 to gcimporter results in:
no buildable Go source files in /home/vagrant/go/src/golang.org/x/tools/go/types
Which is true - there's an additional directory typeutil
I'm using go1.6 darwin/amd64 - has the dependency structure changed for go-1.6?
Adding import for "runtime" causes too many errors.
Source Code:
package main
import "runtime"
import "github.com/d4l3k/go-pry/pry"
func main() {
a := 1
pry.Pry()
}
Result: (note: the undefined runtime.* changes each time)
# command-line-arguments
./main.go:8: undefined: runtime.REG_RDI
./main.go:8: undefined: runtime.REG_R9
./main.go:8: undefined: runtime.REG_DS
./main.go:8: undefined: runtime.REG_CS
./main.go:8: undefined: runtime.REG_RSI
./main.go:8: undefined: runtime.REG_RCX
./main.go:8: undefined: runtime.REG_R11
./main.go:8: undefined: runtime.REG_RBX
./main.go:8: undefined: runtime.REG_RAX
./main.go:8: undefined: runtime.REG_GS
./main.go:8: too many errors
Reverting files
Applogies, I accidently created this issue
but what we(newbies) are getting here looks like this:
go-pry -i "fmt,math,strconv"
From /tmp/pry891096756/main.go @ line 10 :
5: "fmt"
6: "math"
7: "strconv"
8: )
9: func main() {
=> 10: pry.Pry()
11: }
[0] go-pry>
ERR
exec: "gocode": executable file not found in $PATH
PRY magick pop up in that Readme gif looks too awesome.
I guess I am getting the error because of some $PATH issues..
Hi,
I try the example, but it panic
[8] go-pry> panic: rpc: can't find service RPC.RPC_auto_complete
goroutine 1 [running]:
main.client_auto_complete(0xc000160240, 0xc0001c4000, 0x4768, 0x7e00, 0x7ffeefbfee14, 0x3c, 0x2428, 0x14bf5a4, 0x5, 0x14c03ef, ...)
/Users/pathbox/gowork/pkg/mod/github.com/nsf/gocode@v0.0.0-20180902125341-7b1d4e18cdc5/rpc.go:38 +0x20a
main.cmd_auto_complete(0xc000160240)
/Users/pathbox/gowork/pkg/mod/github.com/nsf/gocode@v0.0.0-20180902125341-7b1d4e18cdc5/client.go:164 +0x38f
main.do_client(0x0)
/Users/pathbox/gowork/pkg/mod/github.com/nsf/gocode@v0.0.0-20180902125341-7b1d4e18cdc5/client.go:44 +0x35a
main.main()
/Users/pathbox/gowork/pkg/mod/github.com/nsf/gocode@v0.0.0-20180902125341-7b1d4e18cdc5/gocode.go:71 +0x82
I don't konw the relations with gocode
reflect panic when trying to access an unexported field in a struct. For example :
type A struct {
unexp string
Exp string
}
a := &A{/*.....*/}
Access to a.unexp will panic. Problem is here..
Line 226 in f6e6fbd
I believe there should be a check on field.isValid()
AND sel.isExported()
or not. If exported then field.Interface()
, otherwise need to do something like this.
// ......
if field.IsValid() && sel.IsExported() {
return field.Interface(), nil
} else if field.IsValid() && !sel.IsExported() {
k := rVal.FieldByName(sel.Name)
if k.CanAddr() { // can address
k = reflect.NewAt(k.Type(), unsafe.Pointer(k.UnsafeAddr())).Elem()
} else { // can't address
switch k.Kind() {
case reflect.String:
return k.String(), nil
// ......
default:
return k.Interface(), nil
}
}
return k.Interface(), nil
}
[1] go-pry> x := "hello"
=> "hello"
[2] go-pry> x += " world"
=> " world"
[3] go-pry> x
=> " world"
The same thing in gore (https://github.com/motemen/gore)
gore> x := "hello"
"hello"
gore> x += " world"
"hello world"
Hi,
I've tried go-pry with two different projects and in both instances it would return missing dependency issues. I just want to verify that these dependencies shouldn't be handled internally by go-pry.
Below is the error I'm getting from running pry.Pry()
in my open-source project https://github.com/integralist/Go-Requester/
panic: cannot find package "gopkg.in/check.v1" in any of:
/usr/local/Cellar/go/1.5/libexec/src/gopkg.in/check.v1 (from $GOROOT)
/Users/M/Projects/golang/src/gopkg.in/check.v1 (from $GOPATH)
goroutine 1 [running]:
main.InjectPry(0x82082cf80, 0x35, 0x0, 0x0, 0x0, 0x0)
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:60 +0x1324
main.main.func4(0x82082cf80, 0x35, 0x88206978b8, 0x820a1a690, 0x0, 0x0, 0x0, 0x0)
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:242 +0x1ee
path/filepath.walk(0x82082cf80, 0x35, 0x88206978b8, 0x820a1a690, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:349 +0x80
path/filepath.walk(0x820684fc0, 0x26, 0x88206978b8, 0x820695040, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8206a66a0, 0x1e, 0x88206978b8, 0x820694ff0, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8206a6600, 0x15, 0x88206978b8, 0x820694fa0, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8206a6500, 0x11, 0x88206978b8, 0x820694f00, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8206aa230, 0x6, 0x88206978b8, 0x820694e10, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x309430, 0x1, 0x88206978b8, 0x8204f3630, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.Walk(0x309430, 0x1, 0x820bd9f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:396 +0xe1
main.main()
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:252 +0x9e0
goroutine 5 [syscall]:
os/signal.loop()
/usr/local/Cellar/go/1.5/libexec/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
/usr/local/Cellar/go/1.5/libexec/src/os/signal/signal_unix.go:28 +0x37
goroutine 6 [select, locked to thread]:
runtime.gopark(0x3895d8, 0x820514728, 0x30c978, 0x6, 0x33418, 0x2)
/usr/local/Cellar/go/1.5/libexec/src/runtime/proc.go:185 +0x163
runtime.selectgoImpl(0x820514728, 0x0, 0x18)
/usr/local/Cellar/go/1.5/libexec/src/runtime/select.go:392 +0xa64
runtime.selectgo(0x820514728)
/usr/local/Cellar/go/1.5/libexec/src/runtime/select.go:212 +0x12
runtime.ensureSigM.func1()
/usr/local/Cellar/go/1.5/libexec/src/runtime/signal1_unix.go:227 +0x323
runtime.goexit()
/usr/local/Cellar/go/1.5/libexec/src/runtime/asm_amd64.s:1696 +0x1
goroutine 7 [chan receive]:
main.main.func1(0x8204fa4e0)
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:162 +0x4d
created by main.main
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:164 +0x10c
And here is the feedback from a separate project...
panic: cannot find package "github.com/aws/aws-sdk-go/service/sts" in any of:
/usr/local/Cellar/go/1.5/libexec/src/github.com/aws/aws-sdk-go/service/sts (from $GOROOT)
/Users/M/Projects/golang/src/github.com/aws/aws-sdk-go/service/sts (from $GOPATH)
goroutine 1 [running]:
main.InjectPry(0x8204fa7e0, 0x60, 0x0, 0x0, 0x0, 0x0)
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:60 +0x1324
main.main.func4(0x8204fa7e0, 0x60, 0x88206978b8, 0x820a09a40, 0x0, 0x0, 0x0, 0x0)
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:242 +0x1ee
path/filepath.walk(0x8204fa7e0, 0x60, 0x88206978b8, 0x820a09a40, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:349 +0x80
path/filepath.walk(0x820a09900, 0x48, 0x88206978b8, 0x820a099a0, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x820ba0680, 0x3f, 0x88206978b8, 0x82068f950, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204f4840, 0x33, 0x88206978b8, 0x8204f39a0, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204ed260, 0x2f, 0x88206978b8, 0x8204f3950, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204ed140, 0x24, 0x88206978b8, 0x8204f3900, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204f0940, 0x20, 0x88206978b8, 0x8204f38b0, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204f08a0, 0x15, 0x88206978b8, 0x8204f3860, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204f07a0, 0x11, 0x88206978b8, 0x8204f37c0, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x8204f7f10, 0x6, 0x88206978b8, 0x8204f36d0, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.walk(0x309430, 0x1, 0x88206978b8, 0x8204f3630, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:374 +0x4fc
path/filepath.Walk(0x309430, 0x1, 0x8206f1f00, 0x0, 0x0)
/usr/local/Cellar/go/1.5/libexec/src/path/filepath/path.go:396 +0xe1
main.main()
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:252 +0x9e0
goroutine 5 [syscall]:
os/signal.loop()
/usr/local/Cellar/go/1.5/libexec/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
/usr/local/Cellar/go/1.5/libexec/src/os/signal/signal_unix.go:28 +0x37
goroutine 6 [select, locked to thread]:
runtime.gopark(0x3895d8, 0x820514728, 0x30c978, 0x6, 0x33418, 0x2)
/usr/local/Cellar/go/1.5/libexec/src/runtime/proc.go:185 +0x163
runtime.selectgoImpl(0x820514728, 0x0, 0x18)
/usr/local/Cellar/go/1.5/libexec/src/runtime/select.go:392 +0xa64
runtime.selectgo(0x820514728)
/usr/local/Cellar/go/1.5/libexec/src/runtime/select.go:212 +0x12
runtime.ensureSigM.func1()
/usr/local/Cellar/go/1.5/libexec/src/runtime/signal1_unix.go:227 +0x323
runtime.goexit()
/usr/local/Cellar/go/1.5/libexec/src/runtime/asm_amd64.s:1696 +0x1
goroutine 7 [chan receive]:
main.main.func1(0x8204fa4e0)
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:162 +0x4d
created by main.main
/Users/M/Projects/golang/src/github.com/d4l3k/go-pry/main.go:164 +0x10c
I was looking to use go-pry, as a big fan of pry in Ruby.
I'm quite new to Go, but I have found that if I try to use go-pry on anything that's using more than the fmt package, I get issues.
An example is if I have test.go
as below. Can use go-pry without importing the os package, but not with. I've come across other packages such as path/filepath
that give similar errors.
package main
import "github.com/d4l3k/go-pry/pry"
import "os"
func main() {
pry.Pry()
os.Setenv("foo", "bar")
}
~/dev/go/src/github.com/adamgeorgeson/test$ go-pry run test.go
# command-line-arguments
./test.go:7: duplicate key "Pipe" in map literal
./test.go:7: duplicate key "Interrupt" in map literal
./test.go:7: duplicate key "Kill" in map literal
./test.go:7: duplicate key "Remove" in map literal
./test.go:7: duplicate key "TempDir" in map literal
./test.go:7: duplicate key "NewFile" in map literal
./test.go:7: duplicate key "DevNull" in map literal
./test.go:7: duplicate key "Symlink" in map literal
./test.go:7: duplicate key "OpenFile" in map literal
./test.go:7: too many errors
Reverting files
Cheers,
Adam.
Hi, everyone!
Could you please tell me, can we use go-pry
with Echo
framework https://github.com/labstack/echo?
I've added pry.Pry()
to my code, but didn't have result. I've used go-pry
instead of go
.
Trying to create an array of length 3:
[1] go-pry> var z [3]int
=> <nil>
[2] go-pry> z
=> []int(nil)
[3] go-pry> z[0]
Error: slice index out of range <nil>
Works in gore:
gore> var z [3]int
gore> z
[3]int{
0,
0,
0,
}
gore> z[0]
0
I tried to find docs to know how to setup go-pry in chrome but I couldn't find any. Can you please let me know the setup steps for it ?
Thanks.
Hello,
I have a simple Go code like this :
package main
import (
"net/http"
"github.com/d4l3k/go-pry/pry"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.LoadHTMLGlob("templates/*")
router.Static("/assets", "./assets")
router.GET("/", handleRoot)
router.Run(":1234")
}
func handleRoot(c *gin.Context) {
pry.Apply(&pry.Scope{Vals:map[string]interface{}{ "main": main, "handleRoot": handleRoot, "http": pry.Package{Name: "http", Functions: map[string]interface{}{"ErrBodyReadAfterClose": http.ErrBodyReadAfterClose,"ErrLineTooLong": http.ErrLineTooLong,"SetCookie": http.SetCookie,"MethodHead": http.MethodHead,"MethodPost": http.MethodPost,"MethodPut": http.MethodPut,"MethodPatch": http.MethodPatch,"MethodConnect": http.MethodConnect,"MethodTrace": http.MethodTrace,"MethodGet": http.MethodGet,"MethodDelete": http.MethodDelete,"MethodOptions": http.MethodOptions,"Dir": pry.Type(http.Dir("")),"ServeFile": http.ServeFile,"FileServer": http.FileServer,"ServeContent": http.ServeContent,"StatusPermanentRedirect": http.StatusPermanentRedirect,"StatusPaymentRequired": http.StatusPaymentRequired,"StatusExpectationFailed": http.StatusExpectationFailed,"StatusNotImplemented": http.StatusNotImplemented,"StatusServiceUnavailable": http.StatusServiceUnavailable,"StatusMultipleChoices": http.StatusMultipleChoices,"StatusProxyAuthRequired": http.StatusProxyAuthRequired,"StatusRequestEntityTooLarge": http.StatusRequestEntityTooLarge,"StatusNonAuthoritativeInfo": http.StatusNonAuthoritativeInfo,"StatusMovedPermanently": http.StatusMovedPermanently,"StatusUseProxy": http.StatusUseProxy,"StatusIMUsed": http.StatusIMUsed,"StatusMultiStatus": http.StatusMultiStatus,"StatusUnprocessableEntity": http.StatusUnprocessableEntity,"StatusFailedDependency": http.StatusFailedDependency,"StatusInternalServerError": http.StatusInternalServerError,"StatusOK": http.StatusOK,"StatusRequestTimeout": http.StatusRequestTimeout,"StatusRequestedRangeNotSatisfiable": http.StatusRequestedRangeNotSatisfiable,"StatusInsufficientStorage": http.StatusInsufficientStorage,"StatusSeeOther": http.StatusSeeOther,"StatusPartialContent": http.StatusPartialContent,"StatusUnavailableForLegalReasons": http.StatusUnavailableForLegalReasons,"StatusContinue": http.StatusContinue,"StatusNotAcceptable": http.StatusNotAcceptable,"StatusConflict": http.StatusConflict,"StatusAlreadyReported": http.StatusAlreadyReported,"StatusTeapot": http.StatusTeapot,"StatusPreconditionRequired": http.StatusPreconditionRequired,"StatusUnauthorized": http.StatusUnauthorized,"StatusLocked": http.StatusLocked,"StatusRequestHeaderFieldsTooLarge": http.StatusRequestHeaderFieldsTooLarge,"StatusVariantAlsoNegotiates": http.StatusVariantAlsoNegotiates,"StatusNetworkAuthenticationRequired": http.StatusNetworkAuthenticationRequired,"StatusPreconditionFailed": http.StatusPreconditionFailed,"StatusForbidden": http.StatusForbidden,"StatusLengthRequired": http.StatusLengthRequired,"StatusGatewayTimeout": http.StatusGatewayTimeout,"StatusLoopDetected": http.StatusLoopDetected,"StatusBadRequest": http.StatusBadRequest,"StatusNotExtended": http.StatusNotExtended,"StatusText": http.StatusText,"StatusProcessing": http.StatusProcessing,"StatusMethodNotAllowed": http.StatusMethodNotAllowed,"StatusRequestURITooLong": http.StatusRequestURITooLong,"StatusNoContent": http.StatusNoContent,"StatusHTTPVersionNotSupported": http.StatusHTTPVersionNotSupported,"StatusTooManyRequests": http.StatusTooManyRequests,"StatusNotFound": http.StatusNotFound,"StatusSwitchingProtocols": http.StatusSwitchingProtocols,"StatusGone": http.StatusGone,"StatusUnsupportedMediaType": http.StatusUnsupportedMediaType,"StatusUpgradeRequired": http.StatusUpgradeRequired,"StatusBadGateway": http.StatusBadGateway,"StatusFound": http.StatusFound,"StatusAccepted": http.StatusAccepted,"StatusResetContent": http.StatusResetContent,"StatusNotModified": http.StatusNotModified,"StatusTemporaryRedirect": http.StatusTemporaryRedirect,"StatusCreated": http.StatusCreated,"DefaultClient": http.DefaultClient,"PostForm": http.PostForm,"Head": http.Head,"Get": http.Get,"ErrUseLastResponse": http.ErrUseLastResponse,"Post": http.Post,"DefaultMaxIdleConnsPerHost": http.DefaultMaxIdleConnsPerHost,"ErrSkipAltProtocol": http.ErrSkipAltProtocol,"ProxyFromEnvironment": http.ProxyFromEnvironment,"DefaultTransport": http.DefaultTransport,"ProxyURL": http.ProxyURL,"NoBody": http.NoBody,"NewFileTransport": http.NewFileTransport,"ErrNotMultipart": http.ErrNotMultipart,"ErrNoCookie": http.ErrNoCookie,"MaxBytesReader": http.MaxBytesReader,"ParseHTTPVersion": http.ParseHTTPVersion,"ErrMissingContentLength": http.ErrMissingContentLength,"ErrNotSupported": http.ErrNotSupported,"ErrMissingBoundary": http.ErrMissingBoundary,"ReadRequest": http.ReadRequest,"ErrMissingFile": http.ErrMissingFile,"NewRequest": http.NewRequest,"ErrShortBody": http.ErrShortBody,"ErrHeaderTooLong": http.ErrHeaderTooLong,"ErrUnexpectedTrailer": http.ErrUnexpectedTrailer,"StateActive": http.StateActive,"StateClosed": http.StateClosed,"DefaultMaxHeaderBytes": http.DefaultMaxHeaderBytes,"NotFoundHandler": http.NotFoundHandler,"ErrBodyNotAllowed": http.ErrBodyNotAllowed,"TimeFormat": http.TimeFormat,"DefaultServeMux": http.DefaultServeMux,"ErrServerClosed": http.ErrServerClosed,"NotFound": http.NotFound,"StripPrefix": http.StripPrefix,"ServerContextKey": http.ServerContextKey,"ErrAbortHandler": http.ErrAbortHandler,"LocalAddrContextKey": http.LocalAddrContextKey,"StateHijacked": http.StateHijacked,"Handle": http.Handle,"TrailerPrefix": http.TrailerPrefix,"ListenAndServeTLS": http.ListenAndServeTLS,"RedirectHandler": http.RedirectHandler,"Serve": http.Serve,"NewServeMux": http.NewServeMux,"ErrHijacked": http.ErrHijacked,"ServeTLS": http.ServeTLS,"StateNew": http.StateNew,"ListenAndServe": http.ListenAndServe,"Error": http.Error,"ConnState": pry.Type(http.ConnState(0)),"ErrWriteAfterFlush": http.ErrWriteAfterFlush,"TimeoutHandler": http.TimeoutHandler,"ErrContentLength": http.ErrContentLength,"Redirect": http.Redirect,"HandleFunc": http.HandleFunc,"StateIdle": http.StateIdle,"ErrHandlerTimeout": http.ErrHandlerTimeout,"ErrNoLocation": http.ErrNoLocation,"ReadResponse": http.ReadResponse,"DetectContentType": http.DetectContentType,"Header": pry.Type(http.Header(map[string][]string(nil))),"ParseTime": http.ParseTime,"CanonicalHeaderKey": http.CanonicalHeaderKey,}}, "pry": pry.Package{Name: "pry", Functions: map[string]interface{}{"NewScope": pry.NewScope,"StringToType": pry.StringToType,"ValuesToInterfaces": pry.ValuesToInterfaces,"ErrChanSendFailed": pry.ErrChanSendFailed,"ErrBranchBreak": pry.ErrBranchBreak,"ErrBranchContinue": pry.ErrBranchContinue,"Fuzz": pry.Fuzz,"Type": pry.Type,"Append": pry.Append,"Make": pry.Make,"Close": pry.Close,"Len": pry.Len,"ErrChanRecvInSelect": pry.ErrChanRecvInSelect,"ErrDivisionByZero": pry.ErrDivisionByZero,"DeAssign": pry.DeAssign,"ComputeBinaryOp": pry.ComputeBinaryOp,"ErrChanRecvFailed": pry.ErrChanRecvFailed,"Highlight": pry.Highlight,"Pry": pry.Pry,"Apply": pry.Apply,}}, "gin": pry.Package{Name: "gin", Functions: map[string]interface{}{"AuthUserKey": gin.AuthUserKey,"Accounts": pry.Type(gin.Accounts(map[string]string(nil))),"BasicAuthForRealm": gin.BasicAuthForRealm,"BasicAuth": gin.BasicAuth,"Bind": gin.Bind,"H": pry.Type(gin.H(map[string]interface {}(nil))),"BindKey": gin.BindKey,"WrapH": gin.WrapH,"WrapF": gin.WrapF,"CreateTestContext": gin.CreateTestContext,"Dir": gin.Dir,"DebugMode": gin.DebugMode,"TestMode": gin.TestMode,"DefaultWriter": gin.DefaultWriter,"SetMode": gin.SetMode,"DisableBindValidation": gin.DisableBindValidation,"ENV_GIN_MODE": gin.ENV_GIN_MODE,"DefaultErrorWriter": gin.DefaultErrorWriter,"Mode": gin.Mode,"ReleaseMode": gin.ReleaseMode,"RecoveryWithWriter": gin.RecoveryWithWriter,"Recovery": gin.Recovery,"ErrorLoggerT": gin.ErrorLoggerT,"LoggerWithWriter": gin.LoggerWithWriter,"ErrorLogger": gin.ErrorLogger,"DisableConsoleColor": gin.DisableConsoleColor,"Logger": gin.Logger,"IsDebugging": gin.IsDebugging,"New": gin.New,"Default": gin.Default,"Version": gin.Version,"MIMEJSON": gin.MIMEJSON,"MIMEXML2": gin.MIMEXML2,"MIMEPlain": gin.MIMEPlain,"MIMEPOSTForm": gin.MIMEPOSTForm,"MIMEHTML": gin.MIMEHTML,"MIMEXML": gin.MIMEXML,"MIMEMultipartPOSTForm": gin.MIMEMultipartPOSTForm,"ErrorTypeRender": gin.ErrorTypeRender,"ErrorTypePrivate": gin.ErrorTypePrivate,"ErrorTypePublic": gin.ErrorTypePublic,"ErrorTypeNu": gin.ErrorTypeNu,"ErrorTypeBind": gin.ErrorTypeBind,"ErrorTypeAny": gin.ErrorTypeAny,"ErrorType": pry.Type(gin.ErrorType(0x0)),}}, }})
c.HTML(http.StatusOK, "index.tmpl", nil)
}
The pry part is generated, and I can't print a variable called c
when the breakpoint happens. It says Error: can't find EXPR c <nil>
, while c
is there. Anything wrong with this?
Hi, I was trying to use this amazing project but stumbled upon the issue. Here is output that I'm getting:
panic: interface conversion: interface is nil, not reflect.Type
goroutine 1 [running]:
github.com/d4l3k/go-pry/pry.(*Scope).Interpret(0xc421ac8a20, 0x7feb32653268, 0xc42010e600, 0x7feb32653268, 0xc42010e600, 0x7d9540, 0xc420102620)
/home/gnzh/go-projects/src/github.com/d4l3k/go-pry/pry/interpreter.go:350 +0x24a3
main.GetExports(0xc4202305f8, 0x6, 0xc420d04c00, 0xc4203174a0, 0xc4203174a0, 0x6c4084)
/home/gnzh/go-projects/src/github.com/d4l3k/go-pry/main.go:338 +0x7ce
main.InjectPry(0xc4203242a0, 0x60, 0x6be3c3, 0x3, 0x300000001, 0xc4200001a0)
/home/gnzh/go-projects/src/github.com/d4l3k/go-pry/main.go:77 +0x60c
main.main.func4(0xc420dfac80, 0x3c, 0x7dd1a0, 0xc420dfc0d0, 0x0, 0x0, 0x0, 0x0)
/home/gnzh/go-projects/src/github.com/d4l3k/go-pry/main.go:251 +0xdd
path/filepath.walk(0xc420dfac80, 0x3c, 0x7dd1a0, 0xc420dfc0d0, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:351 +0x81
path/filepath.walk(0xc420dfabc0, 0x34, 0x7dd1a0, 0xc420dfc000, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc42010e120, 0x2d, 0x7dd1a0, 0xc420df4340, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420105ad0, 0x24, 0x7dd1a0, 0xc420259ee0, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420cc0940, 0x17, 0x7dd1a0, 0xc420259e10, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420254420, 0x11, 0x7dd1a0, 0xc4202525b0, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0xc420249388, 0x6, 0x7dd1a0, 0xc4202524e0, 0xc420080db0, 0x0, 0x0)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.walk(0x6be214, 0x1, 0x7dd1a0, 0xc420085860, 0xc420080db0, 0x0, 0x30)
/usr/lib/go/src/path/filepath/path.go:376 +0x414
path/filepath.Walk(0x6be214, 0x1, 0xc420080db0, 0x0, 0x1)
/usr/lib/go/src/path/filepath/path.go:398 +0x14c
main.main()
/home/gnzh/go-projects/src/github.com/d4l3k/go-pry/main.go:259 +0x63d
I'm running go version go1.8.3 linux/amd64
on Arch Linux.
Here is the smallest project that I was able to reproduce the issue in:
https://github.com/Gonzih/go-pry-panic-issue-reproduction-example
Please feel free to ask for any extra information on my setup.
Thanks a lot!
I've installed go-pry with go get install github.com/d4l3k/go-pry
and then install. But I type go-pry
, it panics.
panic: failed to TypeCheck: /var/folders/d6/shfh9g6d181_yz6t3t1016f00000gn/T/pry038927497/main.go:3:2: could not import github.com/d4l3k/go-pry/pry (can't find import: "github.com/d4l3k/go-pry/pry")
goroutine 1 [running]:
github.com/d4l3k/go-pry/pry.Apply(0xc4200b0200)
/Users/ming/go/src/github.com/d4l3k/go-pry/pry/pry.go:86 +0x228
main.main()
/var/folders/d6/shfh9g6d181_yz6t3t1016f00000gn/T/pry038927497/main.go:9 +0x32ea
exit status 2
So, I built it with go build
myself and ran, but same results.
What have I missed?
Hi D413k,
If I read your code correctly you Keys method (in interpreter.go file) does not return a (keys []string) in body of method.
Please review accordingly (see excerpt below).
// Keys returns all keys in scope
func (scope *Scope) Keys() (keys []string) {
currentScope := scope
for currentScope != nil {
for k := range currentScope.Vals {
keys = append(keys, k)
}
currentScope = scope.Parent
}
return
}
After years of REPL use, typing control-d (EOF) to exit is hard-wired in. Could you please add this feature.
running the following code result in assignment count mismatch
go-pry -i="fmt,regexp"
From /var/folders/gb/c5q_qjf50j78rnl3cf3b9t7r0000gn/T/pry459719250/main.go @ line 9 :
4:
5: "fmt"
6: "regexp"
7: )
8: func main() {
=> 9: pry.Pry()
10: }
[11] go-pry> regExpr,err := regexp.Compile("(\\d{4}_\\d{2}_\\d{2}).*\\.txt")
Error: assignment count mismatch: 2 = 1 <nil>
✗ echo $GOPATH
/Users/user/go
✗ go install github.com/d4l3k/go-pry
✗ go-pry run readme.go
panic: failed to TypeCheck: /Users/user/readme.go:5:6: main redeclared in this block
goroutine 1 [running]:
github.com/d4l3k/go-pry/pry.Apply(0xc0000ba280)
/Users/user/go/src/github.com/d4l3k/go-pry/pry/pry.go:28 +0x220
main.main()
/Users/user/xreadme.go:7 +0xf30
exit status 2
2018/11/03 22:44:23 main.go:28: exit status 1
Anyone know a workaround for this?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.