Standard library / net/url

url.ParseRequestURI()

Parse an absolute URI or absolute path as an HTTP request target, not a general relative reference. Expected stdout: '/a\ntrue\n'.

Formal Syntax & Structure

go syntaxgo
func ParseRequestURI(rawURL string) (*URL, error)

Parameters & Attributes

NameTypeDescription
rawURLstringURL string to parse.

Return Value

(*URL, error)

Operation result; check errors and validity indicators when returned.

Working Example

Example Snippetgo
package main
import (  "fmt"  "net/url")
func main() {  fmt.Println(must(url.ParseRequestURI("/a?q=1")).Path)  _, e := url.ParseRequestURI("relative")  fmt.Println(e != nil)}
func must[T any](v T, e error) T {  if e != nil {    panic(e)  }  return v}func check(e error) {  if e != nil {    panic(e)  }}
Go Reference