title: Can golang take a function with unknown number of parameters as an argument to another function
body: <p>Suppose I have a program like below</p>
  
  <pre><code>package main
  
  import "fmt"
  
  func main() {
      Execute(1,One)
  //  Execute(2,Two)
  //  Execute(3,Three)
  }
  
  type Executable func(int)
  
  func Execute(noOfArgs int, fn Executable){
      switch noOfArgs {
          case 1 : fn(1)
  //      case 2 : fn(1,2)
  //      case 3 : fn("1",2,3)
      }
  }
  func One(n int) {
      fmt.Println("Foo = ",n)
  }
  func Two(n1,n2 int) {
      fmt.Println("Foo = ",n1+n2)
  }
  func Three(n1 string,n2,n3 int) {
      fmt.Println("Foo = ",n1+n2+n3)
  }
  </code></pre>
  
  <p>And I would like to make the <code>Execute</code> function as a generic one which can receive functions with different number of arguments of different types, what should be the type of <code>Executable</code> ?</p>
  
  <p>In other words, If I uncomment the commented lines in the above program, it will break. What modification should I make to the line <code>type Executable func(int)</code> to make it working?</p>
  
  <p><strong>PS : Please try to give a generic answer instead of giving a workaround for the exact scenario which I mentioned</strong></p>
  
  <p>EDIT:- This is not a duplicate of <a href="https://stackoverflow.com/questions/32721066/pass-string-to-a-function-that-expects-a-variadic-parameter">this</a> question.
  I am not looking for expanding arguments. I will have <strong>different types</strong> of arguments and different number of arguments</p>
  
  <p>EDIT:- I will explain my scenario more clearly.</p>
  
  <p>I have a BDD style test executor which parses a line of text and execute the function associated with it, with appropriate arguments.</p>
  
  <p>Eg :- </p>
  
  <blockquote>
    <p>Say "greeting" to "someone"</p>
  </blockquote>
  
  <p>and an associated function</p>
  
  <pre><code>func SayGreeting(greeting, person string) {
      fmt.Println(greeting, ", ", person)
  }
  </code></pre>
  
  <p>another line which says</p>
  
  <blockquote>
    <p>Add &lt;2> , &lt;3> and &lt;4></p>
  </blockquote>
  
  <p>and associated function</p>
  
  <pre><code>func AddNum(n1, n2, n3 int) {
      sum := n1 + n2 + n3
      fmt.Println("Sum is : ", sum)
  }
  </code></pre>
  
  <p>I have a mechanism to scan all the functions and add it to a map, with associated scenario. My program knows which function to execute, number of arguments to it and the arguments.</p>
  
  <p>My problem is, how do I make the map generic so that I can store different functions with different number/type of arguments. </p>