Shembull: Zbërthimi i një URL

package main

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

func main() {
    url, err := url.Parse("http://www.example.com/anetari/?emri=Golang&emaili=golang@google.com")

    if err != nil {
        log.Fatal(err)
        return
    }

    fmt.Println(url.Scheme)
    fmt.Println(url.Host)
    fmt.Println(url.Path)
    queryString := url.Query()
    fmt.Println("emri: " + queryString["emri"][0])
    fmt.Println("emaili: " + queryString["emaili"][0])
}

https://play.golang.org/p/vftkwqxsS-L

Rezultati:

http
www.example.com
/anetari/
emri: Golang
emaili: golang@google.com
All Rights Reserved Theme by 404 THEME.