Go中的request.param(…)在哪里

Here is my console:

GET http://localhost:8080/api/photos.json?token=ABCDEFGHIJKLMNOPQRSTUVWXYZ

200 OK
    0   
jquery.js (line 8526)
|Params|    Headers    Response    JSON
token   ABCDEFGHIJKLMNOPQRSTUVWXYZ

I am in the params tab. How do I access this and, for example log token to my terminal window.

In node: request.param('token')

Just use func (*Request) FormValue

FormValue returns the first value for the named component of the query. POST and PUT body parameters take precedence over URL query string values. FormValue calls ParseMultipartForm and ParseForm if necessary. To access multiple values of the same key use ParseForm.

Simple Server

package main

import (
    "fmt"
    "net/http"
)

func main() {
    http.HandleFunc("/", home)
    http.ListenAndServe(":4000", nil)

}

func home(w http.ResponseWriter , r *http.Request) {
    fmt.Fprint(w, "<html><body><h1>Hello ", r.FormValue("token") , "</h1></body></html>")
}

Visit localhost:4000/photos.json?token=ABCDEFGHIJKLMNOPQRSTUVWXYZ you would get

Hello ABCDEFGHIJKLMNOPQRSTUVWXYZ

I suppose you have a http.Request. Let's suppose it's called hr.

Then you can do

hr.ParseForm()

and after that you may use hr.Form which is defined like this :

// Form contains the parsed form data, including both the URL
// field's query parameters and the POST or PUT form data.
// This field is only available after ParseForm is called.
// The HTTP client ignores Form and uses Body instead.
Form url.Values

where url.Values is a map :

type Values map[string][]string

Here's an example of use of a parsed form where I'm only interested in the first value for a given name :

func getFormValue(hr *http.Request, name string) string {
    if values := hr.Form[name]; len(values) > 0 {
        return values[0]
    }
    return ""
}