Answer the question
In order to leave comments, you need to log in
How to extract GET parameter (token) from URL?
The Go server receives a URL with a GET parameter (this is a token) -
https://site.com/Link?$2a$10$/VTT.GtRslGWLhZL5dFoZODGwJxppnCM5
var valueGET = r.URL.Query() // map[$2a$10$/VTT.GtRslGWLhZL5dFoZODGwJxppnCM5:[]]
Answer the question
In order to leave comments, you need to log in
For the Query function to work the way you want - the URL must be like ?param1=value1¶m2=value2, then you can extract values from the map by the keys param1, param2, etc.
I think in your case it is better to use just Split or another suitable function from the strings package.
Here is a working example with Split.
package main
import (
"fmt"
"strings"
)
func main() {
url := `https://site.com/regLink?$2a$10$/VTT.GtRslGWLhZL5d`
result := strings.SplitN(url, `?`, 2)
fmt.Printf("token: %s\n", result[1])
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question