title: What is the generic type for a pointer that implements an interface?
body: <p>I have an interface like this</p>
  <pre><code>type A interface {
    SomeMethod()
  }
  </code></pre>
  <p>I have an implementation of this interface via a struct pointer:</p>
  <pre><code>type Aimpl struct {}
  
  func (a *Aimpl) SomeMethod() {}
  </code></pre>
  <p>I have a generic function that takes in a function with an A parameter like so:</p>
  <pre><code>func Handler[T A](callback func(result T)) {
    // Essentially what I'd like to do is result := &amp;Aimpl{} (or whatever T is)
    callback(result)
  }
  </code></pre>
  <p>Also I should add that I cannot modify the definition of <code>A</code> (it's coming from a library). I've tried this:</p>
  <pre><code>type MyA[T any] interface{
    A
    *T
  }
  </code></pre>
  <p>But this code gives me an error:</p>
  <pre><code>func Handler[P any, T MyA[P]](callback func(result A)) {
      result := new(P)
      callback(result) // result does not implement interface. It's a pointer to a type, not a type
  }
  </code></pre>
  <p>Example here: <a href="https://go.dev/play/p/NVo4plR1R-O" rel="nofollow noreferrer">https://go.dev/play/p/NVo4plR1R-O</a></p>