URL (Roundtrip) in Go

Posted by GoDoc
Public (Editable by Users)

A URL represents a parsed URL (technically, a URI reference).

Go
Edit
package main

import (
	"fmt"
	"log"
	"net/url"
)

func main() {
	// Parse + String preserve the original encoding.
	u, err := url.Parse("https://example.com/foo%2fbar")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(u.Path)
	fmt.Println(u.RawPath)
	fmt.Println(u.String())
}