Skip to content

Instantly share code, notes, and snippets.

@jouyouyun
Created June 18, 2014 03:32
Show Gist options
  • Save jouyouyun/6ce22fad3e38c434e397 to your computer and use it in GitHub Desktop.
Save jouyouyun/6ce22fad3e38c434e397 to your computer and use it in GitHub Desktop.
uri encode/decode
func encodeURI(str string) string {
filepath, ok := objUtil.URIToPath(str)
if !ok {
return ""
}
u := url.URL{}
u.Path = filepath
v, _ := objUtil.PathToFileURI(u.String())
return v
}
func decodeURI(str string) string {
u, err := url.Parse(str)
if err != nil {
Logger.Warningf("Url parse '%s' failed: %v", str, err)
return ""
}
v := u.Scheme + "://" + u.Path
return v
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment