Created
November 16, 2018 14:34
-
-
Save reedobrien/fa8f90722e65bacb45e1770ddf8aad56 to your computer and use it in GitHub Desktop.
URLs w/o string replacement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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