_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/oleiade/tempura/blob/1e4f5790d5066b19bd755d71402bb0b41f1e5ff9/tempura.go#L26-L43
func FromBytes(dir, prefix string, data []byte) (*TempFile, error) { var tmp *TempFile = &TempFile{dir: dir, prefix: prefix} var err error tmp.File, err = ioutil.TempFile(dir, prefix) if err != nil { return nil, err } _, err = tmp.Write(data) if err != nil { return nil, err } tmp.Seek(0, 0) return tmp, nil }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/samples/frameimage/frameimage.go#L35-L60
func Draw(gc draw2d.GraphicContext, png string, dw, dh, margin, lineWidth float64) error { // Draw frame draw2dkit.RoundedRectangle(gc, lineWidth, lineWidth, dw-lineWidth, dh-lineWidth, 100, 100) gc.SetLineWidth(lineWidth) gc.FillStroke() // load the source image source, err := draw2dimg.LoadFromPngFile(png) if err != nil { return err } // Size of source image sw, sh := float64(source.Bounds().Dx()), float64(source.Bounds().Dy()) // Draw image to fit in the frame // TODO Seems to have a transform bug here on draw image scale := math.Min((dw-margin*2)/sw, (dh-margin*2)/sh) gc.Save() gc.Translate((dw-sw*scale)/2, (dh-sh*scale)/2) gc.Scale(scale, scale) gc.Rotate(0.2) gc.DrawImage(source) gc.Restore() return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/easyjson.go#L859-L863
func (v *InspectWorkerParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoServiceworker9(&r, v) return r.Error() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/flagutil/kubernetes_cluster_clients.go#L51-L55
func (o *ExperimentalKubernetesOptions) AddFlags(fs *flag.FlagSet) { fs.StringVar(&o.buildCluster, "build-cluster", "", "Path to kube.Cluster YAML file. If empty, uses the local cluster. All clusters are used as build clusters. Cannot be combined with --kubeconfig.") fs.StringVar(&o.kubeconfig, "kubeconfig", "", "Path to .kube/config file. If empty, uses the local cluster. All contexts other than the default or whichever is passed to --context are used as build clusters. . Cannot be combined with --build-cluster.") fs.StringVar(&o.DeckURI, "deck-url", "", "Deck URI for read-only access to the infrastructure cluster.") }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/y/iterator.go#L202-L207
func (s *MergeIterator) Value() ValueStruct { if len(s.h) == 0 { return ValueStruct{} } return s.h[0].itr.Value() }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L131-L138
func (pc Call) name() string { pcFix := uintptr(pc) - 1 // work around for go issue #7690 fn := runtime.FuncForPC(pcFix) if fn == nil { return "???" } return fn.Name() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L4230-L4234
func (v *EventPaused) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoDebugger40(&r, v) return r.Error() }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/peer_heap.go#L91-L98
func (ph *peerHeap) pushPeer(peerScore *peerScore) { ph.order++ newOrder := ph.order // randRange will affect the deviation of peer's chosenCount randRange := ph.Len()/2 + 1 peerScore.order = newOrder + uint64(ph.rng.Intn(randRange)) heap.Push(ph, peerScore) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/debugger.go#L146-L149
func (p EvaluateOnCallFrameParams) WithIncludeCommandLineAPI(includeCommandLineAPI bool) *EvaluateOnCallFrameParams { p.IncludeCommandLineAPI = includeCommandLineAPI return &p }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/easyjson.go#L480-L484
func (v *StopAllWorkersParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoServiceworker4(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L694-L700
func GetSearchResults(searchID string, fromIndex int64, toIndex int64) *GetSearchResultsParams { return &GetSearchResultsParams{ SearchID: searchID, FromIndex: fromIndex, ToIndex: toIndex, } }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/newapp/api/options.go#L13-L18
func (opts *Options) Validate() error { if opts.Options == nil { opts.Options = &core.Options{} } return opts.Options.Validate() }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_server.go#L76-L90
func (r *ProtocolLXD) GetServerResources() (*api.Resources, error) { if !r.HasExtension("resources") { return nil, fmt.Errorf("The server is missing the required \"resources\" API extension") } resources := api.Resources{} // Fetch the raw value _, err := r.queryStruct("GET", "/resources", nil, "", &resources) if err != nil { return nil, err } return &resources, nil }
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/mocktracer/mockspan.go#L212-L217
func (s *MockSpan) String() string { return fmt.Sprintf( "traceId=%d, spanId=%d, parentId=%d, sampled=%t, name=%s", s.SpanContext.TraceID, s.SpanContext.SpanID, s.ParentID, s.SpanContext.Sampled, s.OperationName) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/schedule/schedule.go#L63-L72
func NewFIFOScheduler() Scheduler { f := &fifo{ resume: make(chan struct{}, 1), donec: make(chan struct{}, 1), } f.finishCond = sync.NewCond(&f.mu) f.ctx, f.cancel = context.WithCancel(context.Background()) go f.run() return f }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/language/proto/generate.go#L75-L93
func RuleName(names ...string) string { base := "root" for _, name := range names { notIdent := func(c rune) bool { return !('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || '0' <= c && c <= '9' || c == '_') } if i := strings.LastIndexFunc(name, notIdent); i >= 0 { name = name[i+1:] } if name != "" { base = name break } } return base + "_proto" }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/taskqueue/taskqueue.go#L140-L149
func NewPOSTTask(path string, params url.Values) *Task { h := make(http.Header) h.Set("Content-Type", "application/x-www-form-urlencoded") return &Task{ Path: path, Payload: []byte(params.Encode()), Header: h, Method: "POST", } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/memory/memory.go#L172-L174
func (p *StopSamplingParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandStopSampling, nil, nil) }
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/install/installer.go#L37-L53
func (i *Installer) CheckInstallation() error { for binary, versionRange := range versionMap { log.Println("[INFO] checking", binary, "within range", versionRange) version, err := i.GetVersionForBinary(binary) if err != nil { return err } if err = i.CheckVersion(binary, version); err != nil { return err } } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/decorate/podspec.go#L77-L132
func LabelsAndAnnotationsForSpec(spec prowapi.ProwJobSpec, extraLabels, extraAnnotations map[string]string) (map[string]string, map[string]string) { jobNameForLabel := spec.Job if len(jobNameForLabel) > validation.LabelValueMaxLength { // TODO(fejta): consider truncating middle rather than end. jobNameForLabel = strings.TrimRight(spec.Job[:validation.LabelValueMaxLength], ".-") logrus.WithFields(logrus.Fields{ "job": spec.Job, "key": kube.ProwJobAnnotation, "value": spec.Job, "truncated": jobNameForLabel, }).Info("Cannot use full job name, will truncate.") } labels := map[string]string{ kube.CreatedByProw: "true", kube.ProwJobTypeLabel: string(spec.Type), kube.ProwJobAnnotation: jobNameForLabel, } if spec.Type != prowapi.PeriodicJob && spec.Refs != nil { labels[kube.OrgLabel] = spec.Refs.Org labels[kube.RepoLabel] = spec.Refs.Repo if len(spec.Refs.Pulls) > 0 { labels[kube.PullLabel] = strconv.Itoa(spec.Refs.Pulls[0].Number) } } for k, v := range extraLabels { labels[k] = v } // let's validate labels for key, value := range labels { if errs := validation.IsValidLabelValue(value); len(errs) > 0 { // try to use basename of a path, if path contains invalid // base := filepath.Base(value) if errs := validation.IsValidLabelValue(base); len(errs) == 0 { labels[key] = base continue } logrus.WithFields(logrus.Fields{ "key": key, "value": value, "errors": errs, }).Warn("Removing invalid label") delete(labels, key) } } annotations := map[string]string{ kube.ProwJobAnnotation: spec.Job, } for k, v := range extraAnnotations { annotations[k] = v } return labels, annotations }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dimg/fileutil.go#L11-L30
func SaveToPngFile(filePath string, m image.Image) error { // Create the file f, err := os.Create(filePath) if err != nil { return err } defer f.Close() // Create Writer from file b := bufio.NewWriter(f) // Write the image into the buffer err = png.Encode(b, m) if err != nil { return err } err = b.Flush() if err != nil { return err } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/external-plugins/cherrypicker/server.go#L484-L499
func (s *Server) getPatch(org, repo, targetBranch string, num int) (string, error) { patch, err := s.ghc.GetPullRequestPatch(org, repo, num) if err != nil { return "", err } localPath := fmt.Sprintf("/tmp/%s_%s_%d_%s.patch", org, repo, num, normalize(targetBranch)) out, err := os.Create(localPath) if err != nil { return "", err } defer out.Close() if _, err := io.Copy(out, bytes.NewBuffer(patch)); err != nil { return "", err } return localPath, nil }
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcnotify/tcnotify.go#L226-L236
func (notify *Notify) ListDenylist_SignedURL(continuationToken, limit string, duration time.Duration) (*url.URL, error) { v := url.Values{} if continuationToken != "" { v.Add("continuationToken", continuationToken) } if limit != "" { v.Add("limit", limit) } cd := tcclient.Client(*notify) return (&cd).SignedURL("/denylist/list", v, duration) }
https://github.com/bcurren/go-ssdp/blob/ae8e7a0ef8a8f119ef439791570ee2a094d1d094/ssdp.go#L47-L62
func Search(st string, mx time.Duration) ([]SearchResponse, error) { conn, err := listenForSearchResponses() if err != nil { return nil, err } defer conn.Close() searchBytes, broadcastAddr := buildSearchRequest(st, mx) // Write search bytes on the wire so all devices can respond _, err = conn.WriteTo(searchBytes, broadcastAddr) if err != nil { return nil, err } return readSearchResponses(conn, mx) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/netutil/netutil.go#L37-L61
func resolveTCPAddrDefault(ctx context.Context, addr string) (*net.TCPAddr, error) { host, port, serr := net.SplitHostPort(addr) if serr != nil { return nil, serr } portnum, perr := net.DefaultResolver.LookupPort(ctx, "tcp", port) if perr != nil { return nil, perr } var ips []net.IPAddr if ip := net.ParseIP(host); ip != nil { ips = []net.IPAddr{{IP: ip}} } else { // Try as a DNS name. ipss, err := net.DefaultResolver.LookupIPAddr(ctx, host) if err != nil { return nil, err } ips = ipss } // randomize? ip := ips[0] return &net.TCPAddr{IP: ip.IP, Port: portnum, Zone: ip.Zone}, nil }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L472-L477
func (s *Skiplist) NewUniIterator(reversed bool) *UniIterator { return &UniIterator{ iter: s.NewIterator(), reversed: reversed, } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L140-L155
func (o Owners) KeepCoveringApprovers(reverseMap map[string]sets.String, knownApprovers sets.String, potentialApprovers []string) sets.String { if len(potentialApprovers) == 0 { o.log.Debug("No potential approvers exist to filter for relevance. Does this repo have OWNERS files?") } keptApprovers := sets.NewString() unapproved := o.temporaryUnapprovedFiles(knownApprovers) for _, suggestedApprover := range o.GetSuggestedApprovers(reverseMap, potentialApprovers).List() { if reverseMap[suggestedApprover].Intersection(unapproved).Len() != 0 { keptApprovers.Insert(suggestedApprover) } } return keptApprovers }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/images.go#L899-L928
func (c *Cluster) ImagesGetByNodeID(id int64) (map[string][]string, error) { images := make(map[string][]string) // key is fingerprint, value is list of projects err := c.Transaction(func(tx *ClusterTx) error { stmt := ` SELECT images.fingerprint, projects.name FROM images LEFT JOIN images_nodes ON images.id = images_nodes.image_id LEFT JOIN nodes ON images_nodes.node_id = nodes.id LEFT JOIN projects ON images.project_id = projects.id WHERE nodes.id = ? ` rows, err := tx.tx.Query(stmt, id) if err != nil { return err } var fingerprint string var projectName string for rows.Next() { err := rows.Scan(&fingerprint, &projectName) if err != nil { return err } images[fingerprint] = append(images[fingerprint], projectName) } return rows.Err() }) return images, err }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/pkg/compression/compression.go#L30-L36
func XzDecompressor(r io.Reader) (io.ReadCloser, error) { r, err := xz.NewReader(r) if err != nil { return nil, err } return ioutil.NopCloser(r), nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/input/easyjson.go#L260-L264
func (v SynthesizeTapGestureParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoInput1(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L5522-L5526
func (v *AwaitPromiseParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime51(&r, v) return r.Error() }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/selection_actions.go#L141-L161
func (s *Selection) Select(text string) error { return s.forEachElement(func(selectedElement element.Element) error { optionXPath := fmt.Sprintf(`./option[normalize-space()="%s"]`, text) optionToSelect := target.Selector{Type: target.XPath, Value: optionXPath} options, err := selectedElement.GetElements(optionToSelect.API()) if err != nil { return fmt.Errorf("failed to select specified option for %s: %s", s, err) } if len(options) == 0 { return fmt.Errorf(`no options with text "%s" found for %s`, text, s) } for _, option := range options { if err := option.Click(); err != nil { return fmt.Errorf(`failed to click on option with text "%s" for %s: %s`, text, s, err) } } return nil }) }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/patch_apps_app_routes_route_parameters.go#L122-L125
func (o *PatchAppsAppRoutesRouteParams) WithApp(app string) *PatchAppsAppRoutesRouteParams { o.SetApp(app) return o }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/urlfetch/urlfetch.go#L52-L58
func Client(ctx context.Context) *http.Client { return &http.Client{ Transport: &Transport{ Context: ctx, }, } }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/selection_properties.go#L64-L66
func (s *Selection) CSS(property string) (string, error) { return s.hasProperty(element.Element.GetCSS, property, "CSS property") }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/tarfile/src.go#L49-L69
func NewSourceFromFile(path string) (*Source, error) { file, err := os.Open(path) if err != nil { return nil, errors.Wrapf(err, "error opening file %q", path) } defer file.Close() // If the file is already not compressed we can just return the file itself // as a source. Otherwise we pass the stream to NewSourceFromStream. stream, isCompressed, err := compression.AutoDecompress(file) if err != nil { return nil, errors.Wrapf(err, "Error detecting compression for file %q", path) } defer stream.Close() if !isCompressed { return &Source{ tarPath: path, }, nil } return NewSourceFromStream(stream) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/commitment.go#L64-L68
func (c *commitment) getCommitIndex() uint64 { c.Lock() defer c.Unlock() return c.commitIndex }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node.go#L327-L397
func (c *ClusterTx) NodeIsEmpty(id int64) (string, error) { // Check if the node has any containers. containers, err := query.SelectStrings(c.tx, "SELECT name FROM containers WHERE node_id=?", id) if err != nil { return "", errors.Wrapf(err, "Failed to get containers for node %d", id) } if len(containers) > 0 { message := fmt.Sprintf( "Node still has the following containers: %s", strings.Join(containers, ", ")) return message, nil } // Check if the node has any images available only in it. images := []struct { fingerprint string nodeID int64 }{} dest := func(i int) []interface{} { images = append(images, struct { fingerprint string nodeID int64 }{}) return []interface{}{&images[i].fingerprint, &images[i].nodeID} } stmt, err := c.tx.Prepare(` SELECT fingerprint, node_id FROM images JOIN images_nodes ON images.id=images_nodes.image_id`) if err != nil { return "", err } defer stmt.Close() err = query.SelectObjects(stmt, dest) if err != nil { return "", errors.Wrapf(err, "Failed to get image list for node %d", id) } index := map[string][]int64{} // Map fingerprints to IDs of nodes for _, image := range images { index[image.fingerprint] = append(index[image.fingerprint], image.nodeID) } fingerprints := []string{} for fingerprint, ids := range index { if len(ids) > 1 { continue } if ids[0] == id { fingerprints = append(fingerprints, fingerprint) } } if len(fingerprints) > 0 { message := fmt.Sprintf( "Node still has the following images: %s", strings.Join(fingerprints, ", ")) return message, nil } // Check if the node has any custom volumes. volumes, err := query.SelectStrings( c.tx, "SELECT name FROM storage_volumes WHERE node_id=? AND type=?", id, StoragePoolVolumeTypeCustom) if err != nil { return "", errors.Wrapf(err, "Failed to get custom volumes for node %d", id) } if len(volumes) > 0 { message := fmt.Sprintf( "Node still has the following custom volumes: %s", strings.Join(volumes, ", ")) return message, nil } return "", nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/robots/issue-creator/sources/triage-filer.go#L364-L372
func (c *Cluster) Title() string { return fmt.Sprintf("Failure cluster [%s...] failed %d builds, %d jobs, and %d tests over %d days", c.Identifier[0:6], c.totalBuilds, c.totalJobs, c.totalTests, c.filer.windowDays, ) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/easyjson.go#L1386-L1390
func (v *GetHistogramParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoBrowser14(&r, v) return r.Error() }
https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/cli/state_store.go#L33-L92
func (options Options) NewStateStore() (state.ClusterStorer, error) { var stateStore state.ClusterStorer switch options.StateStore { case "fs": logger.Info("Selected [fs] state store") stateStore = fs.NewFileSystemStore(&fs.FileSystemStoreOptions{ BasePath: options.StateStorePath, ClusterName: options.Name, }) case "crd": logger.Info("Selected [crd] state store") stateStore = crd.NewCRDStore(&crd.CRDStoreOptions{ BasePath: options.StateStorePath, ClusterName: options.Name, }) case "git": logger.Info("Selected [git] state store") if options.GitRemote == "" { return nil, errors.New("empty GitRemote url. Must specify the link to the remote git repo") } user, _ := gg.Global("user.name") email, _ := gg.Email() stateStore = git.NewJSONGitStore(&git.JSONGitStoreOptions{ BasePath: options.StateStorePath, ClusterName: options.Name, CommitConfig: &git.JSONGitCommitConfig{ Name: user, Email: email, Remote: options.GitRemote, }, }) case "jsonfs": logger.Info("Selected [jsonfs] state store") stateStore = jsonfs.NewJSONFileSystemStore(&jsonfs.JSONFileSystemStoreOptions{ BasePath: options.StateStorePath, ClusterName: options.Name, }) case "s3": logger.Info("Selected [s3] state store") client, err := minio.New(options.BucketEndpointURL, options.S3AccessKey, options.S3SecretKey, options.BucketSSL) if err != nil { return nil, err } stateStore = s3.NewJSONFS3Store(&s3.JSONS3StoreOptions{ BasePath: options.StateStorePath, ClusterName: options.Name, Client: client, BucketOptions: &s3.S3BucketOptions{ EndpointURL: options.BucketEndpointURL, BucketName: options.BucketName, }, }) default: return nil, fmt.Errorf("state store [%s] has an invalid type [%s]", options.Name, options.StateStore) } return stateStore, nil }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/selectable.go#L95-L97
func (s *selectable) FindByName(name string) *Selection { return newSelection(s.session, s.selectors.Append(target.Name, name).Single()) }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L280-L287
func newMessageExchangeSet(log Logger, name string) *messageExchangeSet { return &messageExchangeSet{ name: name, log: log.WithFields(LogField{"exchange", name}), exchanges: make(map[uint32]*messageExchange), expiredExchanges: make(map[uint32]struct{}), } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/webaudio/easyjson.go#L397-L401
func (v *EventContextChanged) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoWebaudio4(&r, v) return r.Error() }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L13920-L13922
func (api *API) TaskLocator(href string) *TaskLocator { return &TaskLocator{Href(href), api} }
https://github.com/rlmcpherson/s3gof3r/blob/864ae0bf7cf2e20c0002b7ea17f4d84fec1abc14/putter.go#L80-L110
func newPutter(url url.URL, h http.Header, c *Config, b *Bucket) (p *putter, err error) { p = new(putter) p.url = url p.c, p.b = new(Config), new(Bucket) *p.c, *p.b = *c, *b p.c.Concurrency = max(c.Concurrency, 1) p.c.NTry = max(c.NTry, 1) p.bufsz = max64(minPartSize, c.PartSize) resp, err := p.retryRequest("POST", url.String()+"?uploads", nil, h) if err != nil { return nil, err } defer checkClose(resp.Body, err) if resp.StatusCode != 200 { return nil, newRespError(resp) } err = xml.NewDecoder(resp.Body).Decode(p) if err != nil { return nil, err } p.ch = make(chan *part) for i := 0; i < p.c.Concurrency; i++ { go p.worker() } p.md5OfParts = md5.New() p.md5 = md5.New() p.sp = bufferPool(p.bufsz) return p, nil }
https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/reader.go#L335-L347
func NewReader(r io.Reader, password string) (*Reader, error) { br, ok := r.(*bufio.Reader) if !ok { br = bufio.NewReader(r) } fbr, err := newFileBlockReader(br, password) if err != nil { return nil, err } rr := new(Reader) rr.init(fbr) return rr, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/gitattributes/gitattributes.go#L70-L101
func (g *Group) load(r io.Reader) error { s := bufio.NewScanner(r) for s.Scan() { // Leading and trailing whitespaces are ignored. l := strings.TrimSpace(s.Text()) // Lines that begin with # are ignored. if l == "" || l[0] == '#' { continue } fs := strings.Fields(l) if len(fs) < 2 { continue } // When the pattern matches the path in question, the attributes listed on the line are given to the path. attributes := sets.NewString(fs[1:]...) if attributes.Has("linguist-generated=true") { p, err := parsePattern(fs[0]) if err != nil { return fmt.Errorf("error parsing pattern: %v", err) } g.LinguistGeneratedPatterns = append(g.LinguistGeneratedPatterns, p) } } if err := s.Err(); err != nil { return fmt.Errorf("scan error: %v", err) } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/accessibility/types.go#L165-L167
func (t *ValueSourceType) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) }
https://github.com/coryb/figtree/blob/e5fa026ccd54e0a6a99b6d81f73bfcc8e6fe6a6b/gen-rawoption.go#L54-L62
func (o *BoolOption) WriteAnswer(name string, value interface{}) error { if v, ok := value.(bool); ok { o.Value = v o.Defined = true o.Source = "prompt" return nil } return fmt.Errorf("Got %T expected %T type: %v", value, o.Value, value) }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/pool.go#L29-L81
func poolList(w http.ResponseWriter, r *http.Request, t auth.Token) error { var teams, poolNames []string isGlobal := false contexts := permission.ContextsForPermission(t, permission.PermAppCreate) contexts = append(contexts, permission.ContextsForPermission(t, permission.PermPoolRead)...) for _, c := range contexts { if c.CtxType == permTypes.CtxGlobal { isGlobal = true break } if c.CtxType == permTypes.CtxTeam { teams = append(teams, c.Value) } if c.CtxType == permTypes.CtxPool { poolNames = append(poolNames, c.Value) } } var pools []pool.Pool var err error if isGlobal { pools, err = pool.ListAllPools() if err != nil { return err } } else { pools, err = pool.ListPossiblePools(teams) if err != nil { return err } if len(poolNames) > 0 { namedPools, err := pool.ListPools(poolNames...) if err != nil { return err } pools = append(pools, namedPools...) } } poolsMap := make(map[string]struct{}) var poolList []pool.Pool for _, p := range pools { if _, ok := poolsMap[p.Name]; ok { continue } poolList = append(poolList, p) poolsMap[p.Name] = struct{}{} } if len(poolList) == 0 { w.WriteHeader(http.StatusNoContent) return nil } w.Header().Set("Content-Type", "application/json") return json.NewEncoder(w).Encode(poolList) }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/cmd/autogazelle/server_unix.go#L36-L52
func startServer() error { exe, err := os.Executable() if err != nil { return err } args := []string{"-server"} args = append(args, os.Args[1:]...) cmd := exec.Command(exe, args...) log.Printf("starting server: %s", strings.Join(cmd.Args, " ")) if err := cmd.Start(); err != nil { return err } if err := cmd.Process.Release(); err != nil { return err } return nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_containers.go#L1686-L1724
func (r *ProtocolLXD) GetContainerConsoleLog(containerName string, args *ContainerConsoleLogArgs) (io.ReadCloser, error) { if !r.HasExtension("console") { return nil, fmt.Errorf("The server is missing the required \"console\" API extension") } // Prepare the HTTP request url := fmt.Sprintf("%s/1.0/containers/%s/console", r.httpHost, url.QueryEscape(containerName)) url, err := r.setQueryAttributes(url) if err != nil { return nil, err } req, err := http.NewRequest("GET", url, nil) if err != nil { return nil, err } // Set the user agent if r.httpUserAgent != "" { req.Header.Set("User-Agent", r.httpUserAgent) } // Send the request resp, err := r.do(req) if err != nil { return nil, err } // Check the return value for a cleaner error if resp.StatusCode != http.StatusOK { _, _, err := lxdParseResponse(resp) if err != nil { return nil, err } } return resp.Body, err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/jenkins/controller.go#L241-L256
func getJenkinsJobs(pjs []prowapi.ProwJob) []BuildQueryParams { jenkinsJobs := []BuildQueryParams{} for _, pj := range pjs { if pj.Complete() { continue } jenkinsJobs = append(jenkinsJobs, BuildQueryParams{ JobName: getJobName(&pj.Spec), ProwJobID: pj.Name, }) } return jenkinsJobs }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/ash/authorizer.go#L98-L132
func Or(a, b *Authorizer) *Authorizer { return A("ash/Or", func(ctx *fire.Context) bool { return a.Matcher(ctx) || b.Matcher(ctx) }, func(ctx *fire.Context) ([]*Enforcer, error) { // check first authorizer if a.Matcher(ctx) { // run callback enforcers, err := a.Handler(ctx) if err != nil { return nil, err } // return on success if enforcers != nil { return enforcers, nil } } // check second authorizer if b.Matcher(ctx) { // run callback enforcers, err := b.Handler(ctx) if err != nil { return nil, err } // return on success if enforcers != nil { return enforcers, nil } } return nil, nil }) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/certificates.go#L18-L48
func (c *Cluster) CertificatesGet() (certs []*CertInfo, err error) { err = c.Transaction(func(tx *ClusterTx) error { rows, err := tx.tx.Query( "SELECT id, fingerprint, type, name, certificate FROM certificates", ) if err != nil { return err } defer rows.Close() for rows.Next() { cert := new(CertInfo) rows.Scan( &cert.ID, &cert.Fingerprint, &cert.Type, &cert.Name, &cert.Certificate, ) certs = append(certs, cert) } return rows.Err() }) if err != nil { return certs, err } return certs, nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/transport.go#L454-L463
func (t *Transport) ActivePeers() (cnt int) { t.mu.RLock() defer t.mu.RUnlock() for _, p := range t.peers { if !p.activeSince().IsZero() { cnt++ } } return cnt }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/db.go#L1044-L1055
func (seq *Sequence) Next() (uint64, error) { seq.Lock() defer seq.Unlock() if seq.next >= seq.leased { if err := seq.updateLease(); err != nil { return 0, err } } val := seq.next seq.next++ return val, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/profiler/easyjson.go#L311-L315
func (v TakeTypeProfileReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler2(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/debugger.go#L236-L239
func (p GetPossibleBreakpointsParams) WithRestrictToFunction(restrictToFunction bool) *GetPossibleBreakpointsParams { p.RestrictToFunction = restrictToFunction return &p }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/stats.go#L88-L108
func (s *Stats) Merge(sts *Stats) { atomic.AddUint64(&s.insertConflicts, sts.insertConflicts) sts.insertConflicts = 0 atomic.AddUint64(&s.readConflicts, sts.readConflicts) sts.readConflicts = 0 atomic.AddInt64(&s.softDeletes, sts.softDeletes) sts.softDeletes = 0 atomic.AddInt64(&s.nodeAllocs, sts.nodeAllocs) sts.nodeAllocs = 0 atomic.AddInt64(&s.nodeFrees, sts.nodeFrees) sts.nodeFrees = 0 atomic.AddInt64(&s.usedBytes, sts.usedBytes) sts.usedBytes = 0 for i, val := range sts.levelNodesCount { if val != 0 { atomic.AddInt64(&s.levelNodesCount[i], val) sts.levelNodesCount[i] = 0 } } }
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/english/common.go#L11-L26
func normalizeApostrophes(word *snowballword.SnowballWord) (numSubstitutions int) { for i, r := range word.RS { switch r { // The rune is one of "\u2019", "\u2018", or "\u201B"; // equivalently, unicode code points 8217, 8216, & 8219. case 8217, 8216, 8219: // (Note: the unicode code point for ' is 39.) word.RS[i] = 39 numSubstitutions += 1 } } return }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/cluster_util.go#L58-L60
func GetClusterFromRemotePeers(lg *zap.Logger, urls []string, rt http.RoundTripper) (*membership.RaftCluster, error) { return getClusterFromRemotePeers(lg, urls, 10*time.Second, true, rt) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/jobs.go#L538-L545
func ClearCompiledRegexes(presubmits []Presubmit) { for i := range presubmits { presubmits[i].re = nil presubmits[i].Brancher.re = nil presubmits[i].Brancher.reSkip = nil presubmits[i].RegexpChangeMatcher.reChanges = nil } }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/resolve/index.go#L112-L135
func (ix *RuleIndex) AddRule(c *config.Config, r *rule.Rule, f *rule.File) { var imps []ImportSpec if rslv := ix.mrslv(r, f.Pkg); rslv != nil { imps = rslv.Imports(c, r, f) } // If imps == nil, the rule is not importable. If imps is the empty slice, // it may still be importable if it embeds importable libraries. if imps == nil { return } record := &ruleRecord{ rule: r, label: label.New(c.RepoName, f.Pkg, r.Name()), file: f, importedAs: imps, } if _, ok := ix.labelMap[record.label]; ok { log.Printf("multiple rules found with label %s", record.label) return } ix.rules = append(ix.rules, record) ix.labelMap[record.label] = record }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/server/server.go#L29-L31
func NewAPIServer(env *serviceenv.ServiceEnv, etcdPrefix string, treeCache *hashtree.Cache, storageRoot string, memoryRequest int64) (APIServer, error) { return newAPIServer(env, etcdPrefix, treeCache, storageRoot, memoryRequest) }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/iterator.go#L90-L96
func (it *Iterator) Delete() { it.s.softDelete(it.curr, &it.s.Stats) // It will observe that current item is deleted // Run delete helper and move to the next possible item it.Next() it.deleted = true }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/flash.go#L39-L43
func (f Flash) persist(session *Session) { b, _ := json.Marshal(f.data) session.Set(flashKey, b) session.Save() }
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/vm/ops.go#L461-L474
func NewLoopVar(idx int, array reflect.Value) *LoopVar { lv := &LoopVar{ Index: idx, Count: idx + 1, Body: array, Size: array.Len(), MaxIndex: array.Len() - 1, PeekNext: nil, PeekPrev: nil, IsFirst: false, IsLast: false, } return lv }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/thrift-gen/typestate.go#L42-L55
func newState(v *parser.Thrift, all map[string]parseState) *State { typedefs := make(map[string]*parser.Type) for k, v := range v.Typedefs { typedefs[k] = v.Type } // Enums are typedefs to an int64. i64Type := &parser.Type{Name: "i64"} for k := range v.Enums { typedefs[k] = i64Type } return &State{typedefs, nil, all} }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/pool/pool.go#L38-L61
func NewPool(kubeClient *kube.Clientset, namespace string, serviceName string, port int, queueSize int64, opts ...grpc.DialOption) (*Pool, error) { endpointsInterface := kubeClient.CoreV1().Endpoints(namespace) watch, err := endpointsInterface.Watch(metav1.ListOptions{ LabelSelector: metav1.FormatLabelSelector(metav1.SetAsLabelSelector( map[string]string{"app": serviceName}, )), Watch: true, }) if err != nil { return nil, err } pool := &Pool{ port: port, endpointsWatch: watch, opts: opts, done: make(chan struct{}), queueSize: queueSize, } pool.connsCond = sync.NewCond(&pool.connsLock) go pool.watchEndpoints() return pool, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/applicationcache/easyjson.go#L176-L180
func (v *GetManifestForFrameReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoApplicationcache1(&r, v) return r.Error() }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/require/require.go#L262-L275
func EqualOneOf(tb testing.TB, expecteds interface{}, actual interface{}, msgAndArgs ...interface{}) { tb.Helper() equal, err := oneOfEquals("expecteds", expecteds, actual) if err != nil { fatal(tb, msgAndArgs, err.Error()) } if !equal { fatal( tb, msgAndArgs, "None of : %#v (expecteds)\n"+ " == %#v (actual)", expecteds, actual) } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_lxc.go#L6553-L6568
func (c *containerLXC) StorageStartSensitive() (bool, error) { // Initialize storage interface for the container. err := c.initStorage() if err != nil { return false, err } var isOurOperation bool if c.IsSnapshot() { isOurOperation, err = c.storage.ContainerSnapshotStart(c) } else { isOurOperation, err = c.storage.ContainerMount(c) } return isOurOperation, err }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2stats/queue.go#L62-L78
func (q *statsQueue) Insert(p *RequestStats) { q.rwl.Lock() defer q.rwl.Unlock() q.back = (q.back + 1) % queueCapacity if q.size == queueCapacity { //dequeue q.totalReqSize -= q.items[q.front].Size q.front = (q.back + 1) % queueCapacity } else { q.size++ } q.items[q.back] = p q.totalReqSize += q.items[q.back].Size }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_pools.go#L896-L911
func (c *Cluster) StoragePoolVolumeDelete(project, volumeName string, volumeType int, poolID int64) error { volumeID, _, err := c.StoragePoolNodeVolumeGetTypeByProject(project, volumeName, volumeType, poolID) if err != nil { return err } err = c.Transaction(func(tx *ClusterTx) error { err := storagePoolVolumeReplicateIfCeph(tx.tx, volumeID, project, volumeName, volumeType, poolID, func(volumeID int64) error { _, err := tx.tx.Exec("DELETE FROM storage_volumes WHERE id=?", volumeID) return err }) return err }) return err }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/storage/storage_transport.go#L206-L280
func (s *storageTransport) ParseReference(reference string) (types.ImageReference, error) { var store storage.Store // Check if there's a store location prefix. If there is, then it // needs to match a store that was previously initialized using // storage.GetStore(), or be enough to let the storage library fill out // the rest using knowledge that it has from elsewhere. if reference[0] == '[' { closeIndex := strings.IndexRune(reference, ']') if closeIndex < 1 { return nil, ErrInvalidReference } storeSpec := reference[1:closeIndex] reference = reference[closeIndex+1:] // Peel off a "driver@" from the start. driverInfo := "" driverSplit := strings.SplitN(storeSpec, "@", 2) if len(driverSplit) != 2 { if storeSpec == "" { return nil, ErrInvalidReference } } else { driverInfo = driverSplit[0] if driverInfo == "" { return nil, ErrInvalidReference } storeSpec = driverSplit[1] if storeSpec == "" { return nil, ErrInvalidReference } } // Peel off a ":options" from the end. var options []string optionsSplit := strings.SplitN(storeSpec, ":", 2) if len(optionsSplit) == 2 { options = strings.Split(optionsSplit[1], ",") storeSpec = optionsSplit[0] } // Peel off a "+runroot" from the new end. runRootInfo := "" runRootSplit := strings.SplitN(storeSpec, "+", 2) if len(runRootSplit) == 2 { runRootInfo = runRootSplit[1] storeSpec = runRootSplit[0] } // The rest is our graph root. rootInfo := storeSpec // Check that any paths are absolute paths. if rootInfo != "" && !filepath.IsAbs(rootInfo) { return nil, ErrPathNotAbsolute } if runRootInfo != "" && !filepath.IsAbs(runRootInfo) { return nil, ErrPathNotAbsolute } store2, err := storage.GetStore(storage.StoreOptions{ GraphDriverName: driverInfo, GraphRoot: rootInfo, RunRoot: runRootInfo, GraphDriverOptions: options, UIDMap: s.defaultUIDMap, GIDMap: s.defaultGIDMap, }) if err != nil { return nil, err } store = store2 } else { // We didn't have a store spec, so use the default. store2, err := s.GetStore() if err != nil { return nil, err } store = store2 } return s.ParseStoreReference(store, reference) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/easyjson.go#L992-L996
func (v *SetDocumentCookieDisabledParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoEmulation11(&r, v) return r.Error() }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/put_apps_app_routes_route_parameters.go#L98-L101
func (o *PutAppsAppRoutesRouteParams) WithApp(app string) *PutAppsAppRoutesRouteParams { o.SetApp(app) return o }
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/part.go#L101-L137
func (p *Part) setupHeaders(r *bufio.Reader, defaultContentType string) error { header, err := readHeader(r, p) if err != nil { return err } p.Header = header ctype := header.Get(hnContentType) if ctype == "" { if defaultContentType == "" { p.addWarning(ErrorMissingContentType, "MIME parts should have a Content-Type header") return nil } ctype = defaultContentType } // Parse Content-Type header. mtype, mparams, minvalidParams, err := parseMediaType(ctype) if err != nil { return err } if mtype == "" && len(mparams) > 0 { p.addWarning( ErrorMissingContentType, "Content-Type header has parameters but no content type") } for i := range minvalidParams { p.addWarning( ErrorMalformedHeader, "Content-Type header has malformed parameter %q", minvalidParams[i]) } p.ContentType = mtype // Set disposition, filename, charset if available. p.setupContentHeaders(mparams) p.Boundary = mparams[hpBoundary] p.ContentID = coding.FromIDHeader(header.Get(hnContentID)) return nil }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/mex.go#L466-L492
func (mexset *messageExchangeSet) stopExchanges(err error) { if mexset.log.Enabled(LogLevelDebug) { mexset.log.Debugf("stopping %v exchanges due to error: %v", mexset.count(), err) } mexset.Lock() shutdown, exchanges := mexset.copyExchanges() mexset.shutdown = true mexset.Unlock() if shutdown { mexset.log.Debugf("mexset has already been shutdown") return } for _, mex := range exchanges { // When there's a connection failure, we want to notify blocked callers that the // call will fail, but we don't want to shutdown the exchange as only the // arg reader/writer should shutdown the exchange. Otherwise, our guarantee // on sendChRefs that there's no references to sendCh is violated since // readers/writers could still have a reference to sendCh even though // we shutdown the exchange and called Done on sendChRefs. if mex.errChNotified.CAS(false, true) { mex.errCh.Notify(err) } } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/types.go#L613-L617
func (pe PushEvent) Branch() string { ref := strings.TrimPrefix(pe.Ref, "refs/heads/") // if Ref is a branch ref = strings.TrimPrefix(ref, "refs/tags/") // if Ref is a tag return ref }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L4966-L4970
func (v GetAllCookiesReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork38(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/debugger.go#L816-L818
func (p *SetPauseOnExceptionsParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetPauseOnExceptions, p, nil) }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dsvg/gc.go#L55-L58
func (gc *GraphicContext) Stroke(paths ...*draw2d.Path) { gc.drawPaths(stroked, paths...) gc.Current.Path.Clear() }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/relay_messages.go#L188-L198
func finishesCall(f *Frame) bool { switch f.messageType() { case messageTypeError: return true case messageTypeCallRes, messageTypeCallResContinue: flags := f.Payload[_flagsIndex] return flags&hasMoreFragmentsFlag == 0 default: return false } }
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/log/filtered/filtered.go#L170-L174
func LowerCaseFilter(filter Filter) Filter { return FilterFunc(func(k string, v interface{}) interface{} { return filter.Filter(strings.ToLower(k), v) }) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/file_snapshot.go#L375-L377
func (s *FileSnapshotSink) Write(b []byte) (int, error) { return s.buffered.Write(b) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/concurrency/stm.go#L89-L102
func NewSTM(c *v3.Client, apply func(STM) error, so ...stmOption) (*v3.TxnResponse, error) { opts := &stmOptions{ctx: c.Ctx()} for _, f := range so { f(opts) } if len(opts.prefetch) != 0 { f := apply apply = func(s STM) error { s.Get(opts.prefetch...) return f(s) } } return runSTM(mkSTM(c, opts), apply) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/pkg/ghclient/wrappers.go#L267-L279
func (c *Client) GetUser(login string) (*github.User, error) { var result *github.User _, err := c.retry( fmt.Sprintf("getting user '%s'", login), func() (*github.Response, error) { var resp *github.Response var err error result, resp, err = c.userService.Get(context.Background(), login) return resp, err }, ) return result, err }
https://github.com/tendermint/go-amino/blob/dc14acf9ef15f85828bfbc561ed9dd9d2a284885/binary-encode.go#L455-L471
func encodeFieldNumberAndTyp3(w io.Writer, num uint32, typ Typ3) (err error) { if (typ & 0xF8) != 0 { panic(fmt.Sprintf("invalid Typ3 byte %v", typ)) } if num < 0 || num > (1<<29-1) { panic(fmt.Sprintf("invalid field number %v", num)) } // Pack Typ3 and field number. var value64 = (uint64(num) << 3) | uint64(typ) // Write uvarint value for field and Typ3. var buf [10]byte n := binary.PutUvarint(buf[:], value64) _, err = w.Write(buf[0:n]) return }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dsvg/converters.go#L138-L154
func optiSprintf(format string, a ...interface{}) string { chunks := strings.Split(format, "%") newChunks := make([]string, len(chunks)) for i, chunk := range chunks { if i != 0 { verb := chunk[0] if verb == 'f' || verb == 'F' { num := a[i-1].(float64) p := strconv.Itoa(getPrec(num, verb == 'F')) chunk = strings.Replace(chunk, string(verb), "."+p+"f", 1) } } newChunks[i] = chunk } format = strings.Join(newChunks, "%") return fmt.Sprintf(format, a...) }
https://github.com/glycerine/rbuf/blob/75b78581bebe959bc9a3df4c5f64e82c187d7531/rbuf.go#L261-L300
func (b *FixedSizeRingBuf) WriteTo(w io.Writer) (n int64, err error) { if b.Readable == 0 { return 0, io.EOF } extent := b.Beg + b.Readable firstWriteLen := intMin(extent, b.N) - b.Beg secondWriteLen := b.Readable - firstWriteLen if firstWriteLen > 0 { m, e := w.Write(b.A[b.Use][b.Beg:(b.Beg + firstWriteLen)]) n += int64(m) b.Advance(m) if e != nil { return n, e } // all bytes should have been written, by definition of // Write method in io.Writer if m != firstWriteLen { return n, io.ErrShortWrite } } if secondWriteLen > 0 { m, e := w.Write(b.A[b.Use][0:secondWriteLen]) n += int64(m) b.Advance(m) if e != nil { return n, e } // all bytes should have been written, by definition of // Write method in io.Writer if m != secondWriteLen { return n, io.ErrShortWrite } } return n, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/easyjson.go#L5767-L5771
func (v *EventChildNodeInserted) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom64(&r, v) return r.Error() }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ss/ssc/codegen_client.go#L1228-L1230
func (r *UserPreference) Locator(api *API) *UserPreferenceLocator { return api.UserPreferenceLocator(r.Href) }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/pkg/sysregistries/system_registries.go#L84-L90
func GetInsecureRegistries(sys *types.SystemContext) ([]string, error) { config, err := loadRegistryConf(sys) if err != nil { return nil, err } return config.Registries.Insecure.Registries, nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/etcdserverpb/gw/rpc.pb.gw.go#L966-L968
func RegisterLeaseHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { return RegisterLeaseHandlerClient(ctx, mux, etcdserverpb.NewLeaseClient(conn)) }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L13051-L13053
func (api *API) SessionLocator(href string) *SessionLocator { return &SessionLocator{Href(href), api} }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/branchprotector/protect.go#L203-L230
func (p *protector) UpdateOrg(orgName string, org config.Org) error { var repos []string if org.Protect != nil { // Strongly opinionated org, configure every repo in the org. rs, err := p.client.GetRepos(orgName, false) if err != nil { return fmt.Errorf("list repos: %v", err) } for _, r := range rs { if !r.Archived { repos = append(repos, r.Name) } } } else { // Unopinionated org, just set explicitly defined repos for r := range org.Repos { repos = append(repos, r) } } for _, repoName := range repos { repo := org.GetRepo(repoName) if err := p.UpdateRepo(orgName, repoName, *repo); err != nil { return fmt.Errorf("update %s: %v", repoName, err) } } return nil }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/admin.go#L157-L168
func (c APIClient) RestoreURL(url string) (retErr error) { restoreClient, err := c.AdminAPIClient.Restore(c.Ctx()) if err != nil { return grpcutil.ScrubGRPC(err) } defer func() { if _, err := restoreClient.CloseAndRecv(); err != nil && retErr == nil { retErr = grpcutil.ScrubGRPC(err) } }() return grpcutil.ScrubGRPC(restoreClient.Send(&admin.RestoreRequest{URL: url})) }