title: Google's 'go' and scope/functions
body: <p>In one of the example servers given at golang.org:  </p>
  
  <pre><code>package main
  
  import (
      "flag"
      "http"
      "io"
      "log"
      "template"
  )
  
  var addr = flag.String("addr", ":1718", "http service address") // Q=17, R=18
  var fmap = template.FormatterMap{
      "html": template.HTMLFormatter,
      "url+html": UrlHtmlFormatter,
  }
  var templ = template.MustParse(templateStr, fmap)
  
  func main() {
      flag.Parse()
      http.Handle("/", http.HandlerFunc(QR))
      err := http.ListenAndServe(*addr, nil)
      if err != nil {
          log.Exit("ListenAndServe:", err)
      }
  }
  
  func QR(c *http.Conn, req *http.Request) {
      templ.Execute(req.FormValue("s"), c)
  }
  
  func UrlHtmlFormatter(w io.Writer, v interface{}, fmt string) {
      template.HTMLEscape(w, []byte(http.URLEscape(v.(string))))
  }
  
  
  const templateStr = `
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;QR Link Generator&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  {.section @}
  &lt;img src="http://chart.apis.google.com/chart?chs=300x300&amp;cht=qr&amp;choe=UTF- 8&amp;chl={@|url+html}"
  /&gt;
  &lt;br&gt;
  {@|html}
  &lt;br&gt;
  &lt;br&gt;
  {.end}
  &lt;form action="/" name=f method="GET"&gt;&lt;input maxLength=1024 size=70
  name=s value="" title="Text to QR Encode"&gt;&lt;input type=submit
  value="Show QR" name=qr&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  `  
  </code></pre>
  
  <p>Why is <code>template.HTMLEscape(w, []byte(http.URLEscape(v.(string))))</code> contained within <code>UrlHtmlFormatter</code>? Why can't it be directly linked to <code>"url+html"</code>?  </p>
  
  <p>Also, how could I change func QR to accept parameter values? What I'd like for it to do is accept a command-line flag in place of <code>req *http.Request</code> ... Thanks in advance...</p>