title: How to define a function type which accepts any number of arguments in Go?
body: <p>I try to write a function which takes any other function and wraps a new function around it. This is what I have tried so far:</p>
  <pre class="lang-golang prettyprint-override"><code>package main
  
  import (
      &quot;fmt&quot;
  )
  
  func protect (unprotected func (...interface{})) (func (...interface{})) {
      return func (args ...interface{}) {
          fmt.Println (&quot;protected&quot;);
          unprotected (args...);
      };
  }
  
  func main () {
      a := func () {
          fmt.Println (&quot;unprotected&quot;);
      };
      b := protect (a);
      b ();
  }
  </code></pre>
  <p>When I compile this I get the error:</p>
  <pre><code>cannot use a (type func()) as type func(...interface { }) in function argument
  </code></pre>
  <p>Why is a function without arguments not compatible to a function with a variable number of arguments? What can I do to make them compatible?</p>
  <p><strong>Update:</strong>
  The protected function should be compatible with the original:</p>
  <pre class="lang-golang prettyprint-override"><code>func take_func_int_int (f func (x int) (y int)) (int) {
      return f (1)
  }
  
  func main () {
  
      a := func (x int) (y int) {
          return 2 * x
      }
      b := protect (a)
  
      take_func_int_int (a)
      take_func_int_int (b)
  }
  </code></pre>