Skip to content

Add feature to show errors if methods/types do not implement interfaces mentioned in documentation #2

@ccarner

Description

@ccarner

Firstly, great plugin!

I was actually considering making a plugin myself to make it easier to deal with go's duck-typed interfaces when I found yours while researching :)
Yours is close to what I was looking for, but here's what I was initially hoping to have:

I want to use go's built in documentation links (square brackets in comments [], which are already parsed/highlighted in the golang VSCode extension so must be already understood by the plugin) to check/enforce implementation of interfaces.

EG:

// MyType implements [MyInterface] (see #1 below)
type MyType struct {}

type MyInterface interface {
   Foo()
}

// MyType implements [MyInterface] (see #2 below)
func (m *MyType) Foo() {...}

In this scenario, the plugin would:

  1. throw an error (in the VScode errors panel) when a type has a comment //MyType implements [MyInterface] but it if it doesn't implement the interface
  2. throw an error when a method on a receiver has a comment like //MyType implements [MyInterface], but the method being implemented is not a method in the mentioned interface. This will help catch if a method is renamed in the interface, or mistyped when implemented.

Any chance this is in scope??

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions