Golang html/template.URLEscaper function example

package html/template

URLQueryEscaper returns the escaped value of the textual representation of its arguments in a form suitable for embedding in a URL query.

Golang html/template.URLEscaper function usage example

 package main

 import (
 "fmt"
 "html/template"
 )

 func main() {

 search := "Zip Unzip"

 finalURL := "http://go-search.org/search?q=" + template.URLQueryEscaper(search)

 fmt.Println(finalURL)

 }

Output :

http://go-search.org/search?q=Zip+Unzip

Reference :

http://golang.org/pkg/html/template/#URLQueryEscaper

Advertisement