简体   繁体   中英

Decoding URL in Go

I am calling an API that is returning a URL in a UTF-8 encoded XML document. The parsing is returning something like http://www.test.com and I want to convert it to http://www.test.com .

I'm struggling to find the right way to do this. Any help would be appreciated!

Edit: this code does what I need, but would have thought there would have been a pre-built function that does something similar to this website: https://www.url-encode-decode.com/

    for _, user := range x.Users {
        a := strings.Replace(user.Username, ":", ":", -1)
        b := strings.Replace(a, "/", "/", -1)
        fmt.Println(b)
    }

只需调用html.UnescapeString("http://www.test.com")得到http://www.test.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM