URL.RequestURI in Go

Posted by GoDoc
Public (Editable by Users)

RequestURI returns the encoded path?query or opaque?query string that would be used in an HTTP request for u.

Go
Edit
package main

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

func main() {
	u, err := url.Parse("https://example.org/path?foo=bar")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(u.RequestURI())
}