You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This won't work. The point of internal packages is that other packages do not get access to them. That includes their interfaces. Hence, you cannot generate a mock for those.
If you own that package yourself, you can move it out of internal. Note though, that you might not want to do that, because it's probably internal for a reason. More generally speaking, I don't recommend mocking interfaces that are not supposed to be public interfaces.
Hi @petergtz ,
I decided not to use an interface, where I was using it before. I'm still wondering though, why generating the mock in the internal package worked, as long as my project was in the normal $GOPATH, but didn't when I moved it outside. Also an error instead of a panic would have been nice :)
Hi, I got the following error when generating mocks outside of the GOPATH:
panic: Loading input failed: exit status 1 caused by:
prog.go:14:2: use of internal package not allowed
goroutine 1 [running]:
github.com/petergtz/pegomock/pegomock/filehandling.GenerateMockSourceCode(0xc42000c5c0, 0x2, 0x2, 0x7fff0d647602, 0x4, 0x0, 0x0, 0xc420000100, 0x7a84a0, 0xc420098010, ...)
/home/----/go/src/github.com/petergtz/pegomock/pegomock/filehandling/filehandling.go:108 +0x5c4
github.com/petergtz/pegomock/pegomock/filehandling.GenerateMockFile(0xc42000c5c0, 0x2, 0x2, 0x7fff0d6475ed, 0xa, 0x7fff0d647602, 0x4, 0x0, 0x0, 0x0, ...)
/home/----/go/src/github.com/petergtz/pegomock/pegomock/filehandling/filehandling.go:62 +0xc3
github.com/petergtz/pegomock/pegomock/filehandling.GenerateMockFileInOutputDir(0xc42000c5c0, 0x2, 0x2, 0xc42001a0f4, 0x20, 0x7fff0d6475ed, 0xa, 0x7fff0d647602, 0x4, 0x0, ...)
/home/----/go/src/github.com/petergtz/pegomock/pegomock/filehandling/filehandling.go:39 +0x162
main.Run(0xc4200a0000, 0x8, 0x8, 0x7a84a0, 0xc420098010, 0xc42013c000, 0xc4200200c0)
/home/----/go/src/github.com/petergtz/pegomock/pegomock/main.go:80 +0x160a
main.main()
/home/----/go/src/github.com/petergtz/pegomock/pegomock/main.go:35 +0x90
It does work with a non internal package and it also works perfectly when I'm generating the mocks in the normal package (inside GOPATH).
The text was updated successfully, but these errors were encountered: