Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea: Generate Method/Function Stub for Un-Implemented Method or Function #2010

Open
mccurdyc opened this issue Oct 6, 2018 · 0 comments
Open
Labels

Comments

@mccurdyc
Copy link

mccurdyc commented Oct 6, 2018

I read the issues and docs and I found (GoImpl and GoGenerate), none of which seem to provide this functionality. This seems like something that would exist, or at least have been considered.

I personally think it could be useful if you could generate a function or method stub for an un-implemented function or method under the cursor. Open to thoughts as this would be something that I would be interested in doing.

package main

import path/to/pkg

var s pkg.S{}

s.UnimplementedMethod(1, 1.0, "one")

pkg.UnimplementedFunction(1, 1.0, "one")

While the cursor was over the UnimplementedMethod method, you could run :GoGenerateStub or something.

package pkg

type S struct {}

func (s *S) UnimplementedMethod(a int, b float64, c string) {}

And it would generate the following and if you hovered over the UnimplementedFunction function.

package pkg
...

func UnimplementedFunction(a int, b float64, c string) {}

Some Complexities to Consider

  • would need to pick up on user's type variable in front of method (i.e., (s *Struct))
  • could also stub return values, but would be more difficult to pick up on types based on use (would we just default to int, defaulting seems unacceptable)

Additional Notes

  • I think GoImpl would be a good place to start looking at how this could be done

This is my first issue on an open source project, so please let me know if I am doing something wrong.

@mccurdyc mccurdyc changed the title idea: Generate Method Stub for Un-Implemented Method idea: Generate Method/Function Stub for Un-Implemented Method or Function Oct 6, 2018
@bhcleek bhcleek added the feature label Nov 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants