id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c8600 | {
for key, value := range headers {
r.Header.Add(key, value)
}
return r
} | |
c8601 | = ioutil.ReadAll(body)
return r
} | |
c8602 | *Response {
r.BodyBuffer = []byte(body)
return r
} | |
c8603 | r.BodyBuffer, r.Error = readAndDecode(data, "json")
return r
} | |
c8604 | r.Error = err
return r
} | |
c8605 | *Response {
r.ResponseDelay = delay
return r
} | |
c8606 | = append(r.Mappers, fn)
return r
} | |
c8607 | mock expectation
exp := NewMock(req, res)
Register(exp)
return req
} | |
c8608 |
return
}
cli.Transport = trans.Transport
} | |
c8609 | mutex.Unlock()
config.Observer = fn
} | |
c8610 | config.NetworkingFilters = append(config.NetworkingFilters, fn)
} | |
c8611 | DefaultMatcher,
}
res.Mock = mock
req.Mock = mock
req.Response = res
return mock
} | |
c8612 | (!m.request.Persisted && m.request.Counter == 0)
} | |
c8613 | req = treq
}
}
// Match
matches, err := m.matcher.Match(req, m.request)
if matches {
m.decrement()
}
return matches, err
} | |
c8614 |
m.request.Counter--
if m.request.Counter == 0 {
m.disabled = true
}
} | |
c8615 | // test matching of file to the argument
if match.File(f, a.Last) {
prediction = append(prediction, f)
}
}
return
}
} | |
c8616 | true
}
file = strings.TrimPrefix(file, "./")
prefix = strings.TrimPrefix(prefix, "./")
return strings.HasPrefix(file, prefix)
} | |
c8617 | info, err := os.Stat(dir); err != nil || !info.IsDir() {
return "./"
}
return fixPathForm(a.Last, dir)
} | |
c8618 | // level deeper and give the user the 'pkg' and all the nested packages within
// that package.
lastPrediction = prediction[0]
a.Last = prediction[0]
prediction = predictLocalAndSystem(a)
}
return
} | |
c8619 | according to given paths
for _, p := range paths {
pkg, err := build.ImportDir(p, 0)
if err != nil {
complete.Log("failed importing directory %s: %s", p, err)
continue
}
directories = append(directories, pkg.Dir)
}
return
} | |
c8620 |
flag.Parse()
return c.Complete()
} | |
c8621 | := c.predict(a)
return options
} | |
c8622 | prediction = append(prediction, sub)
}
return
} | |
c8623 | lastHyphenStart := len(a.Last) != 0 && a.Last[0] == '-'
if flagHyphenStart && !lastHyphenStart {
continue
}
prediction = append(prediction, flag)
}
return
} | |
c8624 | last completed word is a command flag that we need to complete
if predictor, ok := c.Flags[a.LastCompleted]; ok && predictor != nil {
Log("Predicting according to flag %s", a.LastCompleted)
return predictor.Predict(a), true
}
options = append(options, c.Sub.Predict(a)...)
options = append(options, c.Flags.Pre... | |
c8625 | }
// if last is absolute, return path as absolute
if filepath.IsAbs(last) {
return fixDirPath(abs)
}
rel, err := filepath.Rel(workDir, abs)
if err != nil {
return file
}
// fix ./ prefix of path
if rel != "." && strings.HasPrefix(last, ".") {
rel = "./" + rel
}
return fixDirPath(rel)
} | |
c8626 | flags matched,
// returning false should make the real program execute
return false
}
if err != nil {
fmt.Printf("%s failed! %s\n", f.action(), err)
os.Exit(3)
}
fmt.Println("Done!")
return true
} | |
c8627 |
switch strings.ToLower(answer) {
case "y", "yes":
return
default:
fmt.Println("Cancelling...")
os.Exit(1)
}
} | |
c8628 | flags.Lookup(f.UninstallName) == nil {
flags.BoolVar(&f.uninstall, f.UninstallName, false,
fmt.Sprintf("Uninstall completion for %s command", f.Name))
}
if flags.Lookup("y") == nil {
flags.BoolVar(&f.yes, "y", false, "Don't prompt user for typing 'yes' when installing completion")
}
} | |
c8629 | errors.New("Install and uninstall are mutually exclusive")
}
return nil
} | |
c8630 |
continue
}
prediction = append(prediction, p.Predict(a)...)
}
return
})
} | |
c8631 | return nil
}
return p(a)
} | |
c8632 | make(http.Header),
queryStructs: make([]interface{}, 0),
responseDecoder: jsonDecoder{},
}
} | |
c8633 | httpClient == nil {
return s.Doer(http.DefaultClient)
}
return s.Doer(httpClient)
} | |
c8634 | {
s.httpClient = http.DefaultClient
} else {
s.httpClient = doer
}
return s
} | |
c8635 | = "HEAD"
return s.Path(pathURL)
} | |
c8636 | = "GET"
return s.Path(pathURL)
} | |
c8637 | = "POST"
return s.Path(pathURL)
} | |
c8638 | = "PUT"
return s.Path(pathURL)
} | |
c8639 | = "PATCH"
return s.Path(pathURL)
} | |
c8640 | = "DELETE"
return s.Path(pathURL)
} | |
c8641 | = "OPTIONS"
return s.Path(pathURL)
} | |
c8642 | = "TRACE"
return s.Path(pathURL)
} | |
c8643 | = "CONNECT"
return s.Path(pathURL)
} | |
c8644 | *Sling {
s.header.Add(key, value)
return s
} | |
c8645 | *Sling {
s.header.Set(key, value)
return s
} | |
c8646 | s.Set("Authorization", "Basic "+basicAuth(username, password))
} | |
c8647 | *Sling {
s.rawURL = rawURL
return s
} | |
c8648 | == nil {
s.rawURL = baseURL.ResolveReference(pathURL).String()
return s
}
return s
} | |
c8649 | ct := body.ContentType()
if ct != "" {
s.Set(contentType, ct)
}
return s
} | |
c8650 | }
}
req, err := http.NewRequest(s.method, reqURL.String(), body)
if err != nil {
return nil, err
}
addHeaders(req, s.header)
return req, err
} | |
c8651 | for _, value := range values {
urlValues.Add(key, value)
}
}
}
// url.Values format to a sorted "url encoded" string, e.g. "key=val&foo=bar"
reqURL.RawQuery = urlValues.Encode()
return nil
} | |
c8652 | value := range values {
req.Header.Add(key, value)
}
}
} | |
c8653 | return s
}
s.responseDecoder = decoder
return s
} | |
c8654 |
return json.NewDecoder(resp.Body).Decode(v)
} | |
c8655 | {
return &IssueService{
sling: sling.New().Client(httpClient).Base(baseURL),
}
} | |
c8656 | err := s.sling.New().Path("issues").QueryStruct(params).Receive(issues, githubError)
if err == nil {
err = githubError
}
return *issues, resp, err
} | |
c8657 | err := s.sling.New().Get(path).QueryStruct(params).Receive(issues, githubError)
if err == nil {
err = githubError
}
return *issues, resp, err
} | |
c8658 | := s.sling.New().Post(path).BodyJSON(issueBody).Receive(issue, githubError)
if err == nil {
err = githubError
}
return issue, resp, err
} | |
c8659 | i+8 <= end; i += 8 {
k1 := round(0, u64(b[i:i+8:len(b)]))
h ^= k1
h = rol27(h)*prime1 + prime4
}
if i+4 <= end {
h ^= uint64(u32(b[i:i+4:len(b)])) * prime1
h = rol23(h)*prime2 + prime3
i += 4
}
for ; i < end; i++ {
h ^= uint64(b[i]) * prime5
h = rol11(h) * prime1
}
h ^= h >> 33
h *= prime2
h ^... | |
c8660 | d.v4 = -prime1v
d.total = 0
d.n = 0
} | |
c8661 | byte(s>>32),
byte(s>>24),
byte(s>>16),
byte(s>>8),
byte(s),
)
} | |
c8662 | k1
h = rol27(h)*prime1 + prime4
}
if i+4 <= end {
h ^= uint64(u32(d.mem[i:i+4])) * prime1
h = rol23(h)*prime2 + prime3
i += 4
}
for i < end {
h ^= uint64(d.mem[i]) * prime5
h = rol11(h) * prime1
i++
}
h ^= h >> 33
h *= prime2
h ^= h >> 29
h *= prime3
h ^= h >> 32
return h
} | |
c8663 | original interface does
// not support returning an error.
if err != nil {
panic(err)
}
return &Throttler{
HTTPRateLimiter{
RateLimiter: limiter,
VaryBy: vary,
},
}
} | |
c8664 | _, err := redis.String(conn.Do("SELECT", r.db)); err != nil {
conn.Close()
return nil, err
}
}
return conn, nil
} | |
c8665 | ttl = tat.Sub(now)
limited = true
break
}
ttl = newTat.Sub(now)
if tatVal == -1 {
updated, err = g.store.SetIfNotExistsWithTTL(key, newTat.UnixNano(), ttl)
} else {
updated, err = g.store.CompareAndSwapWithTTL(key, tatVal, newTat.UnixNano(), ttl)
}
if err != nil {
return false, rlc, err
... | |
c8666 | != nil {
t.error(w, r, err)
return
}
setRateLimitHeaders(w, context)
if !limited {
h.ServeHTTP(w, r)
} else {
dh := t.DeniedHandler
if dh == nil {
dh = DefaultDeniedHandler
}
dh.ServeHTTP(w, r)
}
})
} | |
c8667 | !ok {
return -1, now, nil
}
return atomic.LoadInt64(valP), now, nil
} | |
c8668 | mutate the value after setting
v := value
if ms.keys != nil {
ms.keys.Add(key, &v)
} else {
ms.m[key] = &v
}
return true, nil
} | |
c8669 | {
valP, ok := ms.get(key, false)
if !ok {
return false, nil
}
return atomic.CompareAndSwapInt64(valP, old, new), nil
} | |
c8670 | := range vb.Headers {
buf.WriteString(strings.ToLower(r.Header.Get(h)) + sep)
}
if vb.Path {
buf.WriteString(r.URL.Path + sep)
}
for _, p := range vb.Params {
buf.WriteString(r.FormValue(p) + sep)
}
for _, c := range vb.Cookies {
ck, err := r.Cookie(c)
if err == nil {
buf.WriteString(ck.Value)
}
... | |
c8671 |
// As of this writing, `lru.New` can only return an error if you pass
// maxKeys <= 0 so this should never occur.
panic(err)
}
return st
} | |
c8672 | an error
// so this should be safe while providing some ability to return errors
// in the future.
panic(err)
}
return st
} | |
c8673 | reflect.TypeOf(err).String(),
}
if m := errorMsgPattern.FindStringSubmatch(msg); m != nil {
ex.Module, ex.Value = m[1], m[2]
}
return ex
} | |
c8674 | == nil {
return ""
}
return e.Stacktrace.Culprit()
} | |
c8675 | error {
return &errWrappedWithExtra{
err: err,
extraInfo: extraInfo,
}
} | |
c8676 |
for k, v := range errWithExtra.ExtraInfo() {
extra[k] = v
}
}
if errWithCause, ok := currentErr.(causer); ok {
currentErr = errWithCause.Cause()
} else {
currentErr = nil
}
}
return extra
} | |
c8677 | "" && frame.Function != "" {
return frame.Module + "." + frame.Function
}
}
return ""
} | |
c8678 | NewStacktraceFrame(fr.PC, fr.Function, fr.File, fr.Line, context, appPackagePrefixes)
if frame != nil {
frames = append(frames, frame)
}
if !more {
break
}
}
// If there are no frames, the entire stacktrace is nil
if len(frames) == 0 {
return nil
}
// Optimize the path where there's only 1 frame
... | |
c8679 | == "goexit" {
return nil
}
if context > 0 {
contextLines, lineIdx := sourceCodeLoader.Load(file, line, context)
if len(contextLines) > 0 {
for i, line := range contextLines {
switch {
case i < lineIdx:
frame.PreContext = append(frame.PreContext, string(line))
case i == lineIdx:
frame.... | |
c8680 | && !strings.Contains(frame.Module, "vendor") && !strings.Contains(frame.Module, "third_party") {
return true
}
}
return false
} | |
c8681 | != -1 {
pack = name[:idx]
name = name[idx+1:]
}
name = strings.Replace(name, "·", ".", -1)
return
} | |
c8682 | < len(filename) {
return trimmed
}
}
return filename
} | |
c8683 | {
return []byte(time.Time(timestamp).UTC().Format(timestampFormat)), nil
} | |
c8684 | string(data))
if err != nil {
return err
}
*timestamp = Timestamp(t)
return nil
} | |
c8685 | := time.Time(timestamp)
return t.Format(format)
} | |
c8686 | {
return json.Marshal([2]string{t.Key, t.Value})
} | |
c8687 | return err
}
*t = Tag{tag[0], tag[1]}
return nil
} | |
c8688 | into map[string]string
tagMap := make(map[string]string)
if err := json.Unmarshal(data, &tagMap); err != nil {
return err
}
// Convert to []Tag
for k, v := range tagMap {
tags = append(tags, Tag{k, v})
}
default:
return ErrUnableToUnmarshalJSON
}
*t = tags
return nil
} | |
c8689 | message,
Interfaces: interfaces,
Extra: extra,
}
} | |
c8690 | {
extra = Extra{}
}
setExtraDefaults(extra)
return &Packet{
Message: message,
Interfaces: interfaces,
Extra: extra,
}
} | |
c8691 |
packet.Tags = append(packet.Tags, Tag{k, v})
}
} | |
c8692 | if inter != nil {
interfaces[inter.Class()] = inter
}
}
if len(interfaces) > 0 {
interfaceJSON, err := json.Marshal(interfaces)
if err != nil {
return nil, err
}
packetJSON[len(packetJSON)-1] = ','
packetJSON = append(packetJSON, interfaceJSON[1:]...)
}
return packetJSON, nil
} | |
c8693 | c.user
i++
}
if c.http != nil {
interfaces[i] = c.http
}
return interfaces
} | |
c8694 | return client, client.SetDSN(dsn)
} | |
c8695 | := newClient(tags)
return client, client.SetDSN(dsn)
} | |
c8696 | joinedRegexp, errs, err)
}
client.mu.Lock()
client.ignoreErrorsRegexp = r
client.mu.Unlock()
return nil
} | |
c8697 | ErrMissingProjectID
}
client.url = uri.String()
if hasSecretKey {
client.authHeader = fmt.Sprintf("Sentry sentry_version=4, sentry_key=%s, sentry_secret=%s", publicKey, secretKey)
} else {
client.authHeader = fmt.Sprintf("Sentry sentry_version=4, sentry_key=%s", publicKey)
}
return nil
} | |
c8698 | defer client.mu.Unlock()
client.release = release
} | |
c8699 | defer client.mu.Unlock()
client.environment = environment
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.