Skip to content

Instantly share code, notes, and snippets.

@reedobrien
Created November 16, 2018 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reedobrien/fa8f90722e65bacb45e1770ddf8aad56 to your computer and use it in GitHub Desktop.
Save reedobrien/fa8f90722e65bacb45e1770ddf8aad56 to your computer and use it in GitHub Desktop.
URLs w/o string replacement
package main
import (
"fmt"
"net/url"
)
func main() {
u := url.URL{
Scheme: "http",
Host: "bing.com",
Path: "search",
RawQuery: "q=dotnet",
}
fmt.Println(u.String())
u.Scheme = "https"
u.Host = "google.com"
q := u.Query()
q.Set("q", "golang")
u.RawQuery = q.Encode()
fmt.Println(u.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment