title: How to use a type parameter in an interface method?
body: <p>I am trying to write a sample program to try and implementing the a data structure using Go generics.</p>
  <p>As part of this I want to define a iterator interface. I have the following code:</p>
  <pre class="lang-golang prettyprint-override"><code>package collection
  
  type Iterator interface {
      ForEachRemaining(action func[T any](T) error) error
      // other methods
  }
  
  </code></pre>
  <p>It keeps giving me following error</p>
  <blockquote>
  <p>function type cannot have type parameters</p>
  </blockquote>
  <p>Moving the type parameter to the method also doesn't work:</p>
  <pre><code>type Iterator interface {
      ForEachRemaining[T any](action func(T) error) error
      // other methods
  }
  </code></pre>
  <p>Gives error:</p>
  <blockquote>
  <p>methods cannot have type parameters</p>
  </blockquote>
  <p>Is there any way to define generic interface</p>