Monday, November 3, 2025
HomeGolangHow do I get the present url with question string - Getting...

How do I get the present url with question string – Getting Assist


What number of ranges of authorization do you want? You talked about 2 ranges.

To get the present URL with question string in Golang, you should use the Request.URL subject of the *http.Request struct. This subject will comprise the total URL of the request, together with the question string.

For instance, the next code will get the present URL with question string:

bundle principal

import (
    "fmt"
    "internet/http"
)

func principal() {
    request, err := http.NewRequest("GET", "https://discussion board.golangbridge.org/", nil)
    if err != nil {
        fmt.Println(err)
        return
    }

    url := request.URL
    fmt.Println(url.String())
}

This code will first create a brand new http.Request object. Then, it’s going to get the URL subject of the request object and print it to the console.

The output of the code would be the full URL of the request, together with the question string.

If you wish to parse the URL and get the web page URL values, you should use the ParseQuery() perform. This perform will parse the question string and return a map of key-value pairs.

I’ve performed with this now. Principally studying scroll place by utilizing Javascript and letting Go fetch subsequent 100 rows from the database. Completely 25,000 information within the database :slight_smile:

Any enchancment strategies are welcome.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments