Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

impl not generating stubs from interface #1769

Closed
danf0rth opened this issue Jul 4, 2018 · 6 comments
Closed

impl not generating stubs from interface #1769

danf0rth opened this issue Jul 4, 2018 · 6 comments

Comments

@danf0rth
Copy link

danf0rth commented Jul 4, 2018

Cannot stub interface: unrecognized interface: user.UserRepository

go version go1.10.2 linux/amd64
Extension version 0.6.84, and i also tried 0.6.85-Beta1

Steps to Reproduce:

  1. Download this repository, if your cannot reproduce bug on your existed projects
  2. Call command Go: Generate interface stubs
  3. Type m MySQLUserRepository user.UserRepository
  4. Error occurred: Cannot stub interface: unrecognized interface: user.UserRepository

File structure is similar to this repo, except all located in internal folder inside of my package.

If I run in terminal impl 'm MySQLUserRepository' user.UserRepository, it works:

func (m MySQLUserRepository) GetByID(ctx context.Context, id int64) (*model.User, error) {
        panic("not implemented")
}

func (m MySQLUserRepository) Update(ctx context.Context, user *model.User) (*model.User, error) {
        panic("not implemented")
}

func (m MySQLUserRepository) Store(ctx context.Context, user *model.User) (*model.User, error) {
        panic("not implemented")
}

func (m MySQLUserRepository) Delete(ctx context.Context, user *model.User) (bool, error) {
        panic("not implemented")
}

Thanks for your attention!

@ramya-rao-a
Copy link
Contributor

Can you try running https://'github.com/josharian/impl from the terminal and see if it is able to generate the stubs as expected? If not, then please log this issue at https://github.com/josharian/impl

@danf0rth
Copy link
Author

As i said before, if i run command in terminal impl 'm MySQLUserRepository' user.UserRepository, it works. It looks like vscode run the impl in wrong directory.
screenshot_2018-07-17_07-44-26

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jul 17, 2018

As i said before,

Sorry, I totally missed that. You are right, passing the cwd when spawning the process that runs impl fixes this issue. The fix will be out in the next update which should be in a few days

Thanks for reporting and the code samples!

@ramya-rao-a
Copy link
Contributor

btw from what I could understand this issue only occurs when inside a folder named "internal". Is that right?

@danf0rth
Copy link
Author

@ramya-rao-a, yes, problem occurs when the interface located in the internal directory

@ramya-rao-a
Copy link
Contributor

The fix for this issue is now out in the latest update (0.6.85) to the Go extension.

@vscodebot vscodebot bot locked and limited conversation to collaborators Sep 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants