title: how to dynamically pass values to Sprintf or Printf
body: <p>If I want to pad a string I could use something like this:</p>
  
  <p><a href="https://play.golang.org/p/ATeUhSP18N" rel="noreferrer">https://play.golang.org/p/ATeUhSP18N</a></p>
  
  <pre><code>package main
  
  import (
      "fmt"
  )
  
  func main() {
      x := fmt.Sprintf("%+20s", "Hello World!")
      fmt.Println(x)
  }
  </code></pre>
  
  <p>From <a href="https://golang.org/pkg/fmt/" rel="noreferrer">https://golang.org/pkg/fmt/</a></p>
  
  <pre><code> +  always print a sign for numeric values; 
      guarantee ASCII-only output for %q (%+q)
   -  pad with spaces on the right rather than the left (left-justify the field)
  </code></pre>
  
  <p>But If I would like to dynamically change the pad size how could I pass the value ?</p>
  
  <p>My first guest was:</p>
  
  <pre><code>x := fmt.Sprintf("%+%ds", 20, "Hello World!")
  </code></pre>
  
  <p>But I get this:</p>
  
  <pre><code>%ds%!(EXTRA int=20, string=Hello World!)
  </code></pre>
  
  <p>Is there a way of doing this without creating a custom pad function what would add spaces either left or right probably using a for loop:</p>
  
  <pre><code>for i := 0; i &lt; n; i++ {
      out += str
  }
  </code></pre>