Skip to content

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

Open
@mccurdyc

Description

@mccurdyc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions