id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c15100 | := e.clipboard.Get()
return s
} | |
c15101 | string) {
e.clipboard.Set(s, false)
} | |
c15102 | append(api.middlewares, middleware...)
} | |
c15103 | newAPI(prefix, api.info.resolver, api.router)
} | |
c15104 | &handler)
api := newAPI(prefix, resolver, r)
handler.API = api
return api
} | |
c15105 |
r := routing.NewHTTPRouter(prefix, &handler)
api := newAPI(prefix, staticResolver, r)
handler.API = api
return api
} | |
c15106 | info: info,
middlewares: make([]HandlerFunc, 0),
contextAllocator: nil,
}
api.contextPool.New = func() interface{} {
if api.contextAllocator != nil {
return api.contextAllocator(api)
}
return api.allocateDefaultContext()
}
return api
} | |
c15107 | r *http.Request) {
for _, middleware := range api.middlewares {
middleware(c, w, r)
}
} | |
c15108 | return err
}
return res.respondWithPagination(response, info, http.StatusOK, paginationLinks, w, r)
}
}
source, ok := resource.source.(FindAll)
if !ok {
return NewHTTPError(nil, "Resource does not implement the FindAll interface", http.StatusNotFound)
}
obj, err := source.FindAl... | |
c15109 | if r.Pagination.First != nil {
ret["first"] = buildLink(baseURL, req, r.Pagination.First)
}
if r.Pagination.Last != nil {
ret["last"] = buildLink(baseURL, req, r.Pagination.Last)
}
return
} | |
c15110 | fmt.Sprintf("%d", s.idCount)
c.ID = id
s.users[id] = &c
s.idCount++
return id
} | |
c15111 | }
return fmt.Sprintf("https://localhost:%d", m.Port)
} | |
c15112 |
if err != nil {
return &Response{}, err
}
user.Chocolates = append(user.Chocolates, &choc)
}
result = append(result, *user)
}
return &Response{Res: result}, nil
} | |
c15113 | &Response{}, err
}
start := sizeI * (numberI - 1)
for i := start; i < start+sizeI; i++ {
if i >= uint64(len(users)) {
break
}
result = append(result, *users[strconv.FormatInt(int64(keys[i]), 10)])
}
} else {
limitI, err := strconv.ParseUint(limit, 10, 64)
if err != nil {
return 0, &Respon... | |
c15114 | choc, err := s.ChocStorage.GetOne(chocolateID)
if err != nil {
return &Response{}, err
}
user.Chocolates = append(user.Chocolates, &choc)
}
return &Response{Res: user}, nil
} | |
c15115 | api2go.NewHTTPError(errors.New("Invalid instance given"), "Invalid instance given", http.StatusBadRequest)
}
id := s.UserStorage.Insert(user)
user.ID = id
return &Response{Res: user, Code: http.StatusCreated}, nil
} | |
c15116 | error) {
err := s.UserStorage.Delete(id)
return &Response{Code: http.StatusNoContent}, err
} | |
c15117 | instance given", http.StatusBadRequest)
}
err := s.UserStorage.Update(user)
return &Response{Res: user, Code: http.StatusNoContent}, err
} | |
c15118 | jsonapi.ReferenceID{
ID: chocolateID,
Type: "chocolates",
Name: "sweets",
})
}
return result
} | |
c15119 | result = append(result, u.Chocolates[key])
}
return result
} | |
c15120 |
u.ChocolatesIDs = IDs
return nil
}
return errors.New("There is no to-many relationship with the name " + name)
} | |
c15121 |
return errors.New("There is no to-many relationship with the name " + name)
} | |
c15122 | must be removed
u.ChocolatesIDs = append(u.ChocolatesIDs[:pos], u.ChocolatesIDs[pos+1:]...)
}
}
}
}
return errors.New("There is no to-many relationship with the name " + name)
} | |
c15123 | params[p.Key] = p.Value
}
handler(w, r, params, make(map[string]interface{}))
}
h.router.Handle(protocol, route, wrappedCallback)
} | |
c15124 | := httprouter.CleanPath(r.URL.Path)
_, params, _ := h.router.Lookup(r.Method, path)
return params.ByName(param)
} | |
c15125 | = make(map[string]interface{})
}
c.keys[key] = value
} | |
c15126 |
value, exists = c.keys[key]
}
return
} | |
c15127 | = make(map[string][]string)
c.Set("QueryParams", qp)
}
return qp.(map[string][]string)
} | |
c15128 | instance given", http.StatusBadRequest)
}
id := c.ChocStorage.Insert(choc)
choc.ID = id
return &Response{Res: choc, Code: http.StatusCreated}, nil
} | |
c15129 | &Response{}, api2go.NewHTTPError(errors.New("Invalid instance given"), "Invalid instance given", http.StatusBadRequest)
}
err := c.ChocStorage.Update(choc)
return &Response{Res: choc, Code: http.StatusNoContent}, err
} | |
c15130 | ok := targetValue.Index(i).Interface().(MarshalIdentifier)
if !ok {
return errors.New("existing structs must implement interface MarshalIdentifier")
}
if record.ID == marshalCasted.GetID() {
targetRecord = targetValue.Index(i).Addr()
break
}
}
if targetRecord == emptyValue || targ... | |
c15131 | castedToMany, ok := target.(UnmarshalToManyRelations)
if !ok {
return fmt.Errorf("struct %s does not implement UnmarshalToManyRelations", reflect.TypeOf(target))
}
IDs := make([]string, len(rel.Data.DataArray))
for index, relData := range rel.Data.DataArray {
IDs[index] = relData.ID
}
err :... | |
c15132 | result = append(result, *s.chocolates[key])
}
sort.Sort(byID(result))
return result
} | |
c15133 |
}
return model.Chocolate{}, fmt.Errorf("Chocolate for id %s not found", id)
} | |
c15134 | s.chocolates[id] = &c
s.idCount++
return id
} | |
c15135 | id %s does not exist", c.ID)
}
s.chocolates[c.ID] = &c
return nil
} | |
c15136 |
return json.Unmarshal(payload, &c.DataArray)
}
return errors.New("expected a JSON encoded object or array")
} | |
c15137 | return json.Marshal(c.DataArray)
}
return json.Marshal(c.DataObject)
} | |
c15138 | err
}
var ok bool
l.Href, ok = obj["href"].(string)
if !ok {
return errors.New(`link object expects a "href" key`)
}
l.Meta, _ = obj["meta"].(map[string]interface{})
return nil
}
return errors.New("expected a JSON encoded string or object")
} | |
c15139 | }
return json.Marshal(map[string]interface{}{
"href": l.Href,
"meta": l.Meta,
})
} | |
c15140 | := json.Marshal(input)
if err != nil {
log.Println(err)
return "{}"
}
return string(data)
} | |
c15141 | %d more errors", e.status, e.msg, len(e.Errors))
if e.err != nil {
msg += ", " + e.err.Error()
}
return msg
} | |
c15142 | rs := []rune(s)
rs[0] = unicode.ToLower(rs[0])
return string(rs)
} | |
c15143 | err != nil {
return nil, err
}
return json.Marshal(document)
} | |
c15144 | return nil, err
}
return json.Marshal(document)
} | |
c15145 | b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, ga.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
return string(b)
} | |
c15146 | }
b = strconv.AppendInt(b, int64(t.Minute()), 10)
b = append(b, rof.timeSeparator...)
if t.Second() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Second()), 10)
b = append(b, []byte{0x20}...)
tz, _ := t.Zone()
if btz, ok := rof.timezones[tz]; ok {
b = append(b, btz...)
} else {
b = a... | |
c15147 | b := make([]byte, 0, 32)
return string(b)
} | |
c15148 | if t.Month() < 10 {
b = append(b, '0')
}
b = strconv.AppendInt(b, int64(t.Month()), 10)
b = append(b, []byte{0x2f}...)
if t.Year() > 0 {
b = strconv.AppendInt(b, int64(t.Year()), 10)
} else {
b = strconv.AppendInt(b, int64(-t.Year()), 10)
}
return string(b)
} | |
c15149 | return pluralsString[14:17]
case PluralRuleFew:
return pluralsString[17:20]
case PluralRuleMany:
return pluralsString[20:24]
case PluralRuleOther:
return pluralsString[24:]
default:
return pluralsString[:7]
}
} | |
c15150 | // ignoring error, because it can't fail as we generated
// the string internally from a real number
f, _ = strconv.ParseInt(s[2:], 10, 64)
}
return
} | |
c15151 | {
s = s[2:]
end := len(s) + 1
for i := end; i >= 0; i-- {
if s[i] != '0' {
end = i + 1
break
}
}
// ignoring error, because it can't fail as we generated
// the string internally from a real number
t, _ = strconv.ParseInt(s[:end], 10, 64)
}
return
} | |
c15152 | return locales.PluralRuleMany
case "other":
return locales.PluralRuleOther
default:
return locales.PluralRuleUnknown
}
} | |
c15153 | string(int32sToBytes(cpuid_low(0x80000003, 0)))
ProcessorBrandString += string(int32sToBytes(cpuid_low(0x80000004, 0)))
} | |
c15154 | err
}
if !charMatches(p[0], '#') && !charMatches(p[1], '+') {
endOfHeaders = false
break
}
line, _, err := r.ReadLine()
if err != nil {
return nil, err
}
out.Write(line)
out.WriteByte('\n')
}
return out.Bytes(), nil
} | |
c15155 | || strings.ToLower(key) == "categories" || strings.ToLower(key) == "aliases":
bTags := bytes.Split(val, []byte(" "))
tags := make([]string, len(bTags))
for idx, tag := range bTags {
tags[idx] = string(tag)
}
out[key] = tags
default:
out[key] = string(val)
}
}
return out, nil
} | |
c15156 | p.inlineCallback['*'] = generateBold
p.inlineCallback['+'] = generateStrikethrough
p.inlineCallback['['] = generateLinkOrImg
return p
} | |
c15157 | "", "")
return OrgOptions(input, renderer)
} | |
c15158 | OrgOptions(input, renderer)
} | |
c15159 | charMatches(data[0], '#') && charMatches(data[1], '+') && !charMatches(data[2], ' ')
} | |
c15160 | offset int) int {
return generator(p, out, data, offset, '=', false, p.r.CodeSpan)
} | |
c15161 | *Encoder) *Encoder {
e.tc = tc
return e
} | |
c15162 | some kind of space
// is required if the encoded value was a number,
// so that the reader knows there aren't more
// digits coming.
enc.write("\n")
return enc.err
} | |
c15163 |
case isNull(s):
output = Null
default:
output = String // if all alternatives have been eliminated, the input is a string
}
return output
} | |
c15164 | it in JSON
buf := new(bytes.Buffer)
e := NewEncoder(buf, ps...)
err = e.Encode(root)
if err != nil {
return nil, err
}
return buf, nil
} | |
c15165 | == nil {
n.Children = map[string]Nodes{}
}
n.Children[s] = append(n.Children[s], c)
} | |
c15166 |
}
if len(children) == 0 {
return nil
}
result = children[0]
}
return result
} | |
c15167 | elem.n.AddChild(dec.attributePrefix+a.Name.Local, &Node{Data: a.Value})
}
case xml.CharData:
// Extract XML data (if any)
elem.n.Data = trimNonGraphic(string(xml.CharData(se)))
case xml.EndElement:
// And add it to its parent list
if elem.parent != nil {
elem.parent.n.AddChild(elem.label, elem.n... | |
c15168 | i
} else {
last = i
}
}
// If first is nil, it means there are no graphic characters
if first == nil {
return ""
}
return string([]rune(s)[*first : last+1])
} | |
c15169 |
valid = v.exists // Valid only if j also exists, since other values could possibly also be nil
break
}
if valid {
return nil
}
return ErrNotNull
} | |
c15170 | PackWithOptions(w, data, &Options{Order: order})
} | |
c15171 | return UnpackWithOptions(r, data, &Options{Order: order})
} | |
c15172 | s := &Sketch{
m: m,
p: precision,
alpha: alpha(float64(m)),
}
if sparse {
s.sparse = true
s.tmpSet = set{}
s.sparseList = newCompressedList(int(m))
} else {
s.regs = newRegisters(m)
}
return s, nil
} | |
c15173 |
tmpSet: sk.tmpSet.Clone(),
sparseList: sk.sparseList.Clone(),
regs: sk.regs.clone(),
}
} | |
c15174 | uint32(sk.sparseList.Len()) > sk.m {
sk.toNormal()
}
}
} | |
c15175 | - sk.b)
sk.b = cpOther.b
} else {
cpOther.regs.rebase(sk.b - cpOther.b)
cpOther.b = sk.b
}
for i, v := range cpOther.regs.tailcuts {
v1 := v.get(0)
if v1 > sk.regs.get(uint32(i)*2) {
sk.regs.set(uint32(i)*2, v1)
}
v2 := v.get(1)
if v2 > sk.regs.get(1+uint32(i)*2) {
sk.regs.set(1+... | |
c15176 | decodeHash(iter.Next(), sk.p, pp)
sk.insert(i, r)
}
sk.sparse = false
sk.tmpSet = nil
sk.sparseList = nil
} | |
c15177 | bool {
x := hash(e)
return sk.InsertHash(x)
} | |
c15178 |
sk.toNormal()
}
}
return true
} else {
i, r := getPosVal(x, sk.p)
return sk.insert(uint32(i), r)
}
} | |
c15179 | == 0 {
est = (sk.alpha * m * (m - ez) / (sum + beta(ez)))
} else {
est = (sk.alpha * m * m / sum)
}
return uint64(est + 0.5)
} | |
c15180 |
}
if m, ok := m.(*image.Gray); ok {
return &MemPImage{
XMemPMagic: MemPMagic,
XRect: m.Bounds(),
XChannels: 1,
XDataType: reflect.Uint8,
XPix: m.Pix,
XStride: m.Stride,
}, true
}
if m, ok := m.(*image.RGBA); ok {
return &MemPImage{
XMemPMagic: MemPMagic,
XRect: m.... | |
c15181 | XPix: pix,
XStride: 3 * w,
XRect: r,
}
} | |
c15182 |
pix := make([]uint8, 6*w*h)
return &RGB48Image{
XPix: pix,
XStride: 6 * w,
XRect: r,
}
} | |
c15183 | _, err := GetInfo(header)
if err != nil {
return
}
config.Width = width
config.Height = height
config.ColorModel = color.RGBAModel
return
} | |
c15184 | if err != nil {
return
}
if m, err = DecodeRGBA(data); err != nil {
return
}
return
} | |
c15185 | {
return encode(w, m, opt)
} | |
c15186 | Pix: pix,
Stride: width,
Rect: image.Rect(0, 0, width, height),
}
return
} | |
c15187 | XPix: pix,
XStride: 3 * width,
XRect: image.Rect(0, 0, width, height),
}
return
} | |
c15188 | Pix: pix,
Stride: 4 * width,
Rect: image.Rect(0, 0, width, height),
}
return
} | |
c15189 | a.fail(fmt.Sprintf("%#v %s %#v", a.src, "does not equal", dst))
}
} | |
c15190 | to be truthy", formatMessages(messages...))
a.fail(message)
}
} | |
c15191 | true to be falsey", formatMessages(messages...))
a.fail(message)
}
} | |
c15192 | u.RawQuery = r.URL.RawQuery
return &u
}
return &WebsocketProxy{Backend: backend}
} | |
c15193 |
} else {
for n := n.FirstChild; n != nil; n = n.NextSibling {
outputXML(&buf, n)
}
}
return buf.String()
} | |
c15194 | nil, err
}
defer resp.Body.Close()
return parse(resp.Body)
} | |
c15195 | {
return &NodeNavigator{curr: top, root: top, attr: -1}
} | |
c15196 | []*Node
for t.MoveNext() {
elems = append(elems, getCurrentNode(t))
}
return elems
} | |
c15197 |
var elem *Node
if t.MoveNext() {
elem = getCurrentNode(t)
}
return elem
} | |
c15198 |
}
for _, metric := range standardMetrics {
metricsList = append(metricsList, metric)
}
p := &Prometheus{
MetricsList: metricsList,
MetricsPath: defaultMetricPath,
ReqCntURLLabelMappingFn: func(c *gin.Context) string {
return c.Request.URL.String() // i.e. by default do nothing, i.e. return URL as is
... | |
c15199 | {
p.Ppg.PushGatewayURL = pushGatewayURL
p.Ppg.MetricsURL = metricsURL
p.Ppg.PushIntervalSeconds = pushIntervalSeconds
p.startPushTicker()
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.