Golang net/url.URL.IsAbs(),Query() and RequestURI() functions example
package net/url
Golang net/url.URL.IsAbs(),Query() and RequestURI() functions usage example
package main
import (
"fmt"
"net/url"
)
func main() {
rawURL := "http://username:password@searchengine.com:8080/testpath/?q=socketloop.com#TestFunc"
parsedURL, err := url.Parse(rawURL)
if err != nil {
panic(err)
}
fmt.Println("Is absolute? : ", parsedURL.IsAbs())
fmt.Println("Query values : ", parsedURL.Query())
fmt.Println("Request URI : ", parsedURL.RequestURI())
}
Output :
Is absolute? : true
Query values : map[q:[socketloop.com]]
Request URI : /testpath/?q=socketloop.com
Reference :
http://golang.org/pkg/net/url/#URL.IsAbs
Advertisement
Something interesting
Tutorials
+16.6k Golang : Generate QR codes for Google Authenticator App and fix "Cannot interpret QR code" error
+11.6k Get form post value in Go
+5.4k Unix/Linux : How to archive and compress entire directory ?
+16.4k Golang : Convert slice to array
+11.6k Golang : Convert(cast) float to int
+29.5k Golang : Saving(serializing) and reading file with GOB
+9.3k Golang : How to get garbage collection data?
+6.9k How to let Facebook Login button redirect to a particular URL ?
+6.9k Golang : How to solve "too many .rsrc sections" error?
+5.8k Golang : Fix opencv.LoadHaarClassifierCascade The node does not represent a user object error
+8.2k Golang : Metaprogramming example of wrapping a function