Created
June 20, 2014 21:20
-
-
Save rickt/df9629c0189fbe479c79 to your computer and use it in GitHub Desktop.
how to properly escape URLs in go
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() { | |
var Url *url.URL | |
Url, err := url.Parse("http://foo.com/images") | |
if err != nil { | |
panic("boom") | |
} | |
Url.Path += "this filename has spaces in it.jpg" | |
fmt.Printf("Encoded URL is %q\n", Url.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment