如何使用Golang HTTP客户端正确设置URL中的路径参数?

I'm using net/http package and i would like to set dynamic values to an POST url:

http://myhost.com/v1/sellers/{id}/whatever

How can i set id values in this path parameter?

If you are trying to add params to a URL before you make a server request you can do something like this.

const (
    sellersURL = "http://myhost.com/v1/sellers"
)

q := url.Values{}
q.Add("id", "1")

req, err := http.NewRequest("POST", sellersURL, strings.NewReader(q.Encode()))
if err != nil {
    return err
}

req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Close = true

resp, err := http.DefaultClient.Do(req)
if err != nil {
    return err
}

There is one place where I saw more elegant way to do this (without fmt.Sprintf): uritemplates