本文整理汇总了Golang中url.Values.Add方法的典型用法代码示例。如果您正苦于以下问题:Golang Values.Add方法的具体用法?Golang Values.Add怎么用?Golang Values.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url.Values
的用法示例。
在下文中一共展示了Values.Add方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
var s string
var v url.Values
s = "Hello "
s = s + "World"
v.Add(blob, "yeah")
fmt.Printf("%s\n", s)
fmt.Println(v)
}
示例2: RetrieveGroups
func (p *YahooContactService) RetrieveGroups(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Group, NextToken, os.Error) {
var m url.Values
m = make(url.Values)
m.Add("count", "max")
if next == nil {
} else if start, ok := next.(int); ok {
m.Add("start", strconv.Itoa(start))
}
resp, err := yahoo.RetrieveCategories(client, m)
if resp == nil || resp.Categories.Categories == nil || len(resp.Categories.Categories) == 0 || err != nil {
return make([]*Group, 0), nil, err
}
groups := make([]*Group, len(resp.Categories.Categories))
externalServiceId := p.ServiceId()
userInfo, err := client.RetrieveUserInfo()
externalUserId := userInfo.Guid()
var useErr os.Error = nil
for i, yahooGroup := range resp.Categories.Categories {
var externalGroupId string
if yahooGroup.Id > 0 {
externalGroupId = strconv.Itoa64(yahooGroup.Id)
}
var origDsocialGroup *dm.Group = nil
dsocialGroupId := ""
if len(externalGroupId) > 0 {
dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
if err != nil {
if useErr == nil {
useErr = err
}
continue
}
if dsocialGroupId != "" {
origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
if err != nil {
if useErr == nil {
useErr = err
}
continue
}
} else {
ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, &yahooGroup)
}
}
var dsocialGroup *dm.Group = dm.YahooCategoryToDsocial(&yahooGroup, origDsocialGroup, dsocialUserId)
groups[i] = &Group{
ExternalServiceId: p.ServiceId(),
ExternalUserId: externalUserId,
ExternalGroupId: externalGroupId,
DsocialUserId: dsocialUserId,
DsocialGroupId: dsocialGroupId,
Value: dsocialGroup,
}
}
return groups, nil, useErr
}
示例3: RetrieveContacts
func (p *YahooContactService) RetrieveContacts(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Contact, NextToken, os.Error) {
var m url.Values
m = make(url.Values)
m.Add("count", "max")
if next == nil {
} else if start, ok := next.(int); ok {
m.Add("start", strconv.Itoa(start))
}
resp, err := yahoo.RetrieveContacts(client, m)
if resp == nil || resp.Contacts.Contacts == nil || len(resp.Contacts.Contacts) == 0 || err != nil {
return make([]*Contact, 0), nil, err
}
contacts := make([]*Contact, len(resp.Contacts.Contacts))
externalServiceId := p.ServiceId()
userInfo, err := client.RetrieveUserInfo()
externalUserId := userInfo.Guid()
var useErr os.Error = nil
for i, yahooContact := range resp.Contacts.Contacts {
externalContactId := strconv.Itoa64(yahooContact.Id)
dsocialContactId := ""
var origDsocialContact *dm.Contact = nil
if len(externalContactId) > 0 {
dsocialContactId, err = ds.DsocialIdForExternalContactId(externalServiceId, externalUserId, dsocialUserId, externalContactId)
if err != nil {
useErr = err
continue
}
if dsocialContactId != "" {
origDsocialContact, _, err = ds.RetrieveDsocialContactForExternalContact(externalServiceId, externalUserId, externalContactId, dsocialUserId)
if err != nil {
useErr = err
continue
}
} else {
ds.StoreExternalContact(externalServiceId, externalUserId, dsocialUserId, externalContactId, &yahooContact)
}
}
dsocialContact := dm.YahooContactToDsocial(&yahooContact, origDsocialContact, dsocialUserId)
contacts[i] = &Contact{
ExternalServiceId: p.ServiceId(),
ExternalUserId: externalUserId,
ExternalContactId: externalContactId,
DsocialUserId: dsocialUserId,
DsocialContactId: dsocialContactId,
Value: dsocialContact,
}
}
return contacts, nil, useErr
}
示例4: NewIssueComment
func (p *PullRequest) NewIssueComment(body string) (*Comment, os.Error) {
url_ := fmt.Sprintf("%v/repos/%v/%v/issues/%v/comments", p.g.apiHost, p.Head.Repo.Name, p.Head.Repo.Owner.Login, p.Number)
params := url.Values{}
params.Add("body", body)
out, err := p.g.makePostRequest(url_, strings.NewReader(params.Encode()))
if err != nil {
return nil, err
}
var comment Comment
err = json.Unmarshal(out, &comment)
if err != nil {
return nil, err
}
return &comment, nil
}
示例5: sesGet
func sesGet(data url.Values) (string, os.Error) {
data.Add("AWSAccessKeyId", accessKey)
urlstr := fmt.Sprintf("%s?%s", endpoint, data.Encode())
endpointURL, _ := url.Parse(urlstr)
headers := map[string][]string{}
now := time.UTC()
date := now.Format("Mon, 02 Jan 2006 15:04:05 -0700")
headers["Date"] = []string{date}
h := hmac.NewSHA256([]uint8(secretKey))
h.Write([]uint8(date))
signature := base64.StdEncoding.EncodeToString(h.Sum())
auth := fmt.Sprintf("AWS3-HTTPS AWSAccessKeyId=%s, Algorithm=HmacSHA256, Signature=%s", accessKey, signature)
headers["X-Amzn-Authorization"] = []string{auth}
req := http.Request{
URL: endpointURL,
Method: "GET",
ProtoMajor: 1,
ProtoMinor: 1,
Close: true,
Header: headers,
}
r, err := http.DefaultClient.Do(&req)
if err != nil {
return "", err
}
resultbody, _ := ioutil.ReadAll(r.Body)
r.Body.Close()
if r.StatusCode != 200 {
return "", os.NewError(string(resultbody))
}
return string(resultbody), nil
}
示例6: Send
// optional params for "options" map are:
//
// label: label describing the "application" (used only if being sent from a User account; the Service label is automatically applied if being sent from a Service account)
// title: name of "notification event
// uri: the uri that will be loaded when the notification is opened; if specified, must be urlencoded; if a web address, must start with http:// or https://
//
func (nc *Client) Send(to string, msg string, options ...M) os.Error {
data := url.Values{}
data.Add("to", to)
data.Add("msg", msg)
// grab optional parameters
for _, option := range options {
for k, v := range option {
data.Add(k, v)
}
}
_, err := nc.request("/send_notification", data)
return err
}
示例7: Subscribe
// Register a client
func (nc *Client) Subscribe(username string) os.Error {
data := url.Values{}
data.Add("username", username)
_, err := nc.request("/subscribe_user", data)
return err
}
示例8: RetrieveGroups
func (p *GoogleContactService) RetrieveGroups(client oauth2_client.OAuth2Client, ds DataStoreService, dsocialUserId string, next NextToken) ([]*Group, NextToken, os.Error) {
var m url.Values
if next == nil {
} else if s, ok := next.(string); ok {
if s != "" {
if strings.HasPrefix(s, "https://www.google.com/") {
uri, err := url.Parse(s)
if err == nil {
q, err := url.ParseQuery(uri.RawQuery)
if err == nil {
m = q
}
}
}
if m == nil {
m = make(url.Values)
m.Add("q", s)
}
}
} else if maxResults, ok := next.(int); ok {
m = make(url.Values)
m.Add("max-results", strconv.Itoa(maxResults))
} else if maxResults, ok := next.(int64); ok {
m = make(url.Values)
m.Add("max-results", strconv.Itoa64(maxResults))
} else if gq, ok := next.(*google.GroupQuery); ok {
m = make(url.Values)
if gq.Alt != "" {
m.Add("alt", gq.Alt)
}
if gq.Q != "" {
m.Add("q", gq.Q)
}
if gq.MaxResults > 0 {
m.Add("max-results", strconv.Itoa64(gq.MaxResults))
}
if gq.StartIndex > 0 {
m.Add("start-index", strconv.Itoa64(gq.StartIndex))
}
if gq.UpdatedMin != "" {
m.Add("updated-min", gq.UpdatedMin)
}
if gq.OrderBy != "" {
m.Add("orderby", gq.OrderBy)
}
if gq.ShowDeleted {
m.Add("showdeleted", "true")
}
if gq.RequireAllDeleted {
m.Add("requirealldeleted", "true")
}
if gq.SortOrder != "" {
m.Add("sortorder", gq.SortOrder)
}
}
resp, err := google.RetrieveGroups(client, m)
var theNextToken NextToken = nil
if resp != nil && resp.Feed != nil && resp.Feed.Links != nil && len(resp.Feed.Links) > 0 {
for _, link := range resp.Feed.Links {
if link.Rel == "next" {
theNextToken = link.Href
}
}
}
if resp == nil || resp.Feed == nil || resp.Feed.Entries == nil || len(resp.Feed.Entries) == 0 || err != nil {
return make([]*Group, 0), theNextToken, err
}
groups := make([]*Group, len(resp.Feed.Entries))
externalServiceId := p.ServiceId()
userInfo, err := client.RetrieveUserInfo()
externalUserId := userInfo.Guid()
var useErr os.Error = nil
for i, googleGroup := range resp.Feed.Entries {
externalGroupId := googleGroup.GroupId()
var origDsocialGroup *dm.Group = nil
dsocialGroupId := ""
if len(externalGroupId) > 0 {
dsocialGroupId, err = ds.DsocialIdForExternalGroupId(externalServiceId, externalUserId, dsocialUserId, externalGroupId)
if err != nil {
if useErr == nil {
useErr = err
}
continue
}
if dsocialGroupId != "" {
origDsocialGroup, _, err = ds.RetrieveDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId)
if err != nil {
if useErr == nil {
useErr = err
}
continue
}
} else {
ds.StoreExternalGroup(externalServiceId, externalUserId, dsocialUserId, externalGroupId, &googleGroup)
}
}
var dsocialGroup *dm.Group = dm.GoogleGroupToDsocial(&googleGroup, origDsocialGroup, dsocialUserId)
groups[i] = &Group{
ExternalServiceId: p.ServiceId(),
ExternalUserId: googleGroup.GroupUserId(),
//.........这里部分代码省略.........