<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Brian</title>
    <description>The latest articles on DEV Community by Brian (@winterxhrown).</description>
    <link>https://dev.to/winterxhrown</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F878974%2F8f28c1a3-efb0-4951-a7b2-363a0c23885c.png</url>
      <title>DEV Community: Brian</title>
      <link>https://dev.to/winterxhrown</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/winterxhrown"/>
    <language>en</language>
    <item>
      <title>Generics function as an argument of another function</title>
      <dc:creator>Brian</dc:creator>
      <pubDate>Sat, 18 Jun 2022 05:57:03 +0000</pubDate>
      <link>https://dev.to/winterxhrown/generics-function-as-an-argument-of-another-function-351</link>
      <guid>https://dev.to/winterxhrown/generics-function-as-an-argument-of-another-function-351</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
type genericType Interface{
 type1 | type2 | type3
}
type genericFn[T genericType](req, resp T) T

func test[T genericType](fn genericFn[T]) {}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;appreciate guys do me a big favor.&lt;br&gt;
I am wondering how to pass a function supporting generictype as an argument to another function?&lt;/p&gt;

&lt;p&gt;I got problems when I passed a parameter with type1 among the genericType, then compiler told me type1 is not the type of genericType. &lt;/p&gt;

&lt;p&gt;As I passed a function implemented genericFn, I cannot passed any argument in it. &lt;/p&gt;

&lt;p&gt;does anybody know what’s going on or willing to share some use case?&lt;/p&gt;

&lt;p&gt;thanks a lot ! &lt;/p&gt;

</description>
      <category>go</category>
      <category>generic</category>
    </item>
  </channel>
</rss>
