_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage/quota/projectquota.go#L193-L205
func Supported(path string) (bool, error) { // Get the backing device devPath, err := devForPath(path) if err != nil { return false, err } // Call quotactl through CGo cDevPath := C.CString(devPath) defer C.free(unsafe.Pointer(cDevPath)) return C.quota_supported(cDevPath) == 0, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/page.go#L1299-L1304
func AddCompilationCache(url string, data string) *AddCompilationCacheParams { return &AddCompilationCacheParams{ URL: url, Data: data, } }
https://github.com/knq/sdhook/blob/41b9ccbff0b5fa5a56fbdccf2eb8653e7afe8d4b/opts.go#L70-L87
func HTTPClient(client *http.Client) Option { return func(sh *StackdriverHook) error { // create logging service l, err := logging.New(client) if err != nil { return err } // create error reporting service e, err := errorReporting.New(client) if err != nil { return err } else { ErrorService(e) } return LoggingService(l)(sh) } }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/log/log.go#L176-L188
func protoToAppLogs(logLines []*pb.LogLine) []AppLog { appLogs := make([]AppLog, len(logLines)) for i, line := range logLines { appLogs[i] = AppLog{ Time: time.Unix(0, *line.Time*1e3), Level: int(*line.Level), Message: *line.LogMessage, } } return appLogs }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/jobs.go#L290-L297
func (cm RegexpChangeMatcher) RunsAgainstChanges(changes []string) bool { for _, change := range changes { if cm.reChanges.MatchString(change) { return true } } return false }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/easyjson.go#L963-L967
func (v *HighlightQuadParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoOverlay10(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/emulation.go#L117-L119
func (p *SetFocusEmulationEnabledParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandSetFocusEmulationEnabled, p, nil) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L1087-L1091
func (v ReleaseObjectParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime10(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L360-L371
func (f *FakeClient) ListTeams(org string) ([]github.Team, error) { return []github.Team{ { ID: 0, Name: "Admins", }, { ID: 42, Name: "Leads", }, }, nil }
https://github.com/scorredoira/email/blob/c1787f8317a847a7adc13673be80723268e6e639/email.go#L122-L134
func (m *Message) Tolist() []string { tolist := m.To for _, cc := range m.Cc { tolist = append(tolist, cc) } for _, bcc := range m.Bcc { tolist = append(tolist, bcc) } return tolist }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/db/storage.go#L123-L128
func (s *Storage) Users() *storage.Collection { emailIndex := mgo.Index{Key: []string{"email"}, Unique: true} c := s.Collection("users") c.EnsureIndex(emailIndex) return c }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/clientset/versioned/fake/clientset_generated.go#L80-L82
func (c *Clientset) Prow() prowv1.ProwV1Interface { return &fakeprowv1.FakeProwV1{Fake: &c.Fake} }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/browser.go#L416-L419
func (p SetDockTileParams) WithImage(image string) *SetDockTileParams { p.Image = image return &p }
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/context.go#L173-L183
func (ctx *Context) GetSession() IStore { store := ctx.Data["session"] if store == nil { return nil } st, ok := store.(IStore) if ok == false { return nil } return st }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/auth/cmds/cmds.go#L401-L432
func ModifyAdminsCmd(noMetrics, noPortForwarding *bool) *cobra.Command { var add []string var remove []string modifyAdmins := &cobra.Command{ Short: "Modify the current cluster admins", Long: "Modify the current cluster admins. --add accepts a comma-" + "separated list of users to grant admin status, and --remove accepts a " + "comma-separated list of users to revoke admin status", Run: cmdutil.Run(func([]string) error { c, err := client.NewOnUserMachine(!*noMetrics, !*noPortForwarding, "user") if err != nil { return err } defer c.Close() _, err = c.ModifyAdmins(c.Ctx(), &auth.ModifyAdminsRequest{ Add: add, Remove: remove, }) if auth.IsErrPartiallyActivated(err) { return fmt.Errorf("%v: if pachyderm is stuck in this state, you "+ "can revert by running 'pachctl auth deactivate' or retry by "+ "running 'pachctl auth activate' again", err) } return grpcutil.ScrubGRPC(err) }), } modifyAdmins.PersistentFlags().StringSliceVar(&add, "add", []string{}, "Comma-separated list of users to grant admin status") modifyAdmins.PersistentFlags().StringSliceVar(&remove, "remove", []string{}, "Comma-separated list of users revoke admin status") return cmdutil.CreateAlias(modifyAdmins, "auth modify-admins") }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/helpers.go#L174-L180
func toVerb(text string) (res string) { res = strings.ToUpper(string(text[0])) + strings.ToLower(text[1:]) if text == "GET" || text == "POST" { res += "Raw" } return }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L6364-L6368
func (v CreateStyleSheetParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss59(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/layertree/layertree.go#L188-L191
func (p ProfileSnapshotParams) WithMinDuration(minDuration float64) *ProfileSnapshotParams { p.MinDuration = minDuration return &p }
https://github.com/enaml-ops/enaml/blob/4f847ee10b41afca41fe09fa839cb2f6ade06fb5/deploymentmanifest.go#L189-L194
func (s *DeploymentManifest) AddTag(key, value string) { if s.Tags == nil { s.Tags = make(map[string]string) } s.Tags[key] = value }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/easyjson.go#L1744-L1748
func (v EventScreenshotRequested) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoOverlay17(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/functional/rpcpb/member.go#L319-L361
func (m *Member) RestoreSnapshot(lg *zap.Logger) (err error) { if err = os.RemoveAll(m.EtcdOnSnapshotRestore.DataDir); err != nil { return err } if err = os.RemoveAll(m.EtcdOnSnapshotRestore.WALDir); err != nil { return err } lg.Info( "snapshot restore START", zap.String("member-name", m.Etcd.Name), zap.Strings("member-client-urls", m.Etcd.AdvertiseClientURLs), zap.String("snapshot-path", m.SnapshotPath), ) now := time.Now() mgr := snapshot.NewV3(lg) err = mgr.Restore(snapshot.RestoreConfig{ SnapshotPath: m.SnapshotInfo.SnapshotPath, Name: m.EtcdOnSnapshotRestore.Name, OutputDataDir: m.EtcdOnSnapshotRestore.DataDir, OutputWALDir: m.EtcdOnSnapshotRestore.WALDir, PeerURLs: m.EtcdOnSnapshotRestore.AdvertisePeerURLs, InitialCluster: m.EtcdOnSnapshotRestore.InitialCluster, InitialClusterToken: m.EtcdOnSnapshotRestore.InitialClusterToken, SkipHashCheck: false, // TODO: set SkipHashCheck it true, to recover from existing db file }) took := time.Since(now) lg.Info( "snapshot restore END", zap.String("member-name", m.SnapshotInfo.MemberName), zap.Strings("member-client-urls", m.SnapshotInfo.MemberClientURLs), zap.String("snapshot-path", m.SnapshotPath), zap.String("snapshot-file-size", m.SnapshotInfo.SnapshotFileSize), zap.String("snapshot-total-size", m.SnapshotInfo.SnapshotTotalSize), zap.Int64("snapshot-total-key", m.SnapshotInfo.SnapshotTotalKey), zap.Int64("snapshot-hash", m.SnapshotInfo.SnapshotHash), zap.Int64("snapshot-revision", m.SnapshotInfo.SnapshotRevision), zap.String("took", took.String()), zap.Error(err), ) return err }
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcawsprovisioner/tcawsprovisioner.go#L383-L387
func (awsProvisioner *AwsProvisioner) Ping() error { cd := tcclient.Client(*awsProvisioner) _, _, err := (&cd).APICall(nil, "GET", "/ping", nil, nil) return err }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/indexeddb/indexeddb.go#L303-L312
func (p *RequestDatabaseNamesParams) Do(ctx context.Context) (databaseNames []string, err error) { // execute var res RequestDatabaseNamesReturns err = cdp.Execute(ctx, CommandRequestDatabaseNames, p, &res) if err != nil { return nil, err } return res.DatabaseNames, nil }
https://github.com/kubicorn/kubicorn/blob/c4a4b80994b4333709c0f8164faabd801866b986/pkg/reconciler.go#L51-L109
func GetReconciler(known *cluster.Cluster, runtimeParameters *RuntimeParameters) (reconciler cloud.Reconciler, err error) { switch known.ProviderConfig().Cloud { case cluster.CloudGoogle: sdk, err := googleSDK.NewSdk() if err != nil { return nil, err } gr.Sdk = sdk return cloud.NewAtomicReconciler(known, compute.NewGoogleComputeModel(known)), nil case cluster.CloudDigitalOcean: sdk, err := godoSdk.NewSdk() if err != nil { return nil, err } dr.Sdk = sdk return cloud.NewAtomicReconciler(known, droplet.NewDigitalOceanDropletModel(known)), nil case cluster.CloudAmazon: awsProfile := "" if runtimeParameters != nil { awsProfile = runtimeParameters.AwsProfile } sdk, err := awsSdkGo.NewSdk(known.ProviderConfig().Location, awsProfile) if err != nil { return nil, err } ar.Sdk = sdk return cloud.NewAtomicReconciler(known, awspub.NewAmazonPublicModel(known)), nil case cluster.CloudAzure: sdk, err := azureSDK.NewSdk() if err != nil { return nil, err } azr.Sdk = sdk return cloud.NewAtomicReconciler(known, azpub.NewAzurePublicModel(known)), nil case cluster.CloudOVH: sdk, err := openstackSdk.NewSdk(known.ProviderConfig().Location) if err != nil { return nil, err } osr.Sdk = sdk return cloud.NewAtomicReconciler(known, osovh.NewOvhPublicModel(known)), nil case cluster.CloudPacket: sdk, err := packetSDK.NewSdk() if err != nil { return nil, err } packetr.Sdk = sdk return cloud.NewAtomicReconciler(known, packetpub.NewPacketPublicModel(known)), nil case cluster.CloudECS: sdk, err := openstackSdk.NewSdk(known.ProviderConfig().Location) if err != nil { return nil, err } osr.Sdk = sdk return cloud.NewAtomicReconciler(known, osecs.NewEcsPublicModel(known)), nil default: return nil, fmt.Errorf("Invalid cloud type: %s", known.ProviderConfig().Cloud) } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/author_filter_wrapper.go#L41-L43
func (a *AuthorFilterPluginWrapper) AddFlags(cmd *cobra.Command) { cmd.Flags().StringSliceVar(&a.ignoredAuthors, "ignore-authors", []string{}, "Name of people to ignore") }
https://github.com/tendermint/go-amino/blob/dc14acf9ef15f85828bfbc561ed9dd9d2a284885/decoder.go#L151-L167
func DecodeBool(bz []byte) (b bool, n int, err error) { const size int = 1 if len(bz) < size { err = errors.New("EOF decoding bool") return } switch bz[0] { case 0: b = false case 1: b = true default: err = errors.New("invalid bool") } n = size return }
https://github.com/gopistolet/gospf/blob/a58dd1fcbf509d558a6809c54defbce6872c40c5/spf.go#L570-L662
func (spf *SPF) CheckIP(ip_str string) (string, error) { ip := net.ParseIP(ip_str) for _, ip_net := range spf.Fail { if ip_net.Contains(ip) { return "Fail", nil } } for _, ip_net := range spf.SoftFail { if ip_net.Contains(ip) { return "SoftFail", nil } } for _, ip_net := range spf.Neutral { if ip_net.Contains(ip) { return "Neutral", nil } } for _, ip_net := range spf.Pass { if ip_net.Contains(ip) { return "Pass", nil } } for _, include := range spf.Includes { /* RFC 7208 5.2 The "include" mechanism triggers a recursive evaluation of check_host(). 1. The <domain-spec> is expanded as per Section 7. 2. check_host() is evaluated with the resulting string as the <domain>. The <ip> and <sender> arguments remain the same as in the current evaluation of check_host(). 3. The recursive evaluation returns match, not-match, or an error. 4. If it returns match, then the appropriate result for the "include" mechanism is used (e.g., include or +include produces a "pass" result and -include produces "fail"). 5. If it returns not-match or an error, the parent check_host() resumes processing as per the table below, with the previous value of <domain> restored. +---------------------------------+---------------------------------+ | A recursive check_host() result | Causes the "include" mechanism | | of: | to: | +---------------------------------+---------------------------------+ | pass | match | | | | | fail | not match | | | | | softfail | not match | | | | | neutral | not match | | | | | temperror | return temperror | | | | | permerror | return permerror | | | | | none | return permerror | +---------------------------------+---------------------------------+ */ check, err := include.spf.CheckIP(ip_str) if err != nil { return "", nil } if check == "Pass" { return qualifierToResult(include.qualifier), nil } } // Check redirects /* RFC 7208 6.1. For clarity, any "redirect" modifier SHOULD appear as the very last term in a record. Any "redirect" modifier MUST be ignored if there is an "all" mechanism anywhere in the record. */ if spf.All == "undefined" { if spf.Redirect != nil { return spf.Redirect.CheckIP(ip_str) } } // No results found -> check all if spf.All != "undefined" { return qualifierToResult(spf.All), nil } return "None", nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L2853-L2857
func (v GetHeapUsageParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime26(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L100-L110
func NewPFSInputOpts(name string, repo string, branch string, glob string, lazy bool) *pps.Input { return &pps.Input{ Pfs: &pps.PFSInput{ Name: name, Repo: repo, Branch: branch, Glob: glob, Lazy: lazy, }, } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/daemon.go#L1255-L1314
func initializeDbObject(d *Daemon) (*db.Dump, error) { logger.Info("Initializing local database") // Rename the old database name if needed. if shared.PathExists(d.os.LegacyLocalDatabasePath()) { if shared.PathExists(d.os.LocalDatabasePath()) { return nil, fmt.Errorf("Both legacy and new local database files exists") } logger.Info("Renaming local database file from lxd.db to database/local.db") err := os.Rename(d.os.LegacyLocalDatabasePath(), d.os.LocalDatabasePath()) if err != nil { return nil, errors.Wrap(err, "Failed to rename legacy local database file") } } // NOTE: we use the legacyPatches parameter to run a few // legacy non-db updates that were in place before the // patches mechanism was introduced in lxd/patches.go. The // rest of non-db patches will be applied separately via // patchesApplyAll. See PR #3322 for more details. legacy := map[int]*db.LegacyPatch{} for i, patch := range legacyPatches { legacy[i] = &db.LegacyPatch{ Hook: func(node *sql.DB) error { // FIXME: Use the low-level *node* SQL db as backend for both the // db.Node and db.Cluster objects, since at this point we // haven't migrated the data to the cluster database yet. cluster := d.cluster defer func() { d.cluster = cluster }() d.db = db.ForLegacyPatches(node) d.cluster = db.ForLocalInspection(node) return patch(d) }, } } for _, i := range legacyPatchesNeedingDB { legacy[i].NeedsDB = true } // Hook to run when the local database is created from scratch. It will // create the default profile and mark all patches as applied. freshHook := func(db *db.Node) error { for _, patchName := range patchesGetNames() { err := db.PatchesMarkApplied(patchName) if err != nil { return err } } return nil } var err error var dump *db.Dump d.db, dump, err = db.OpenNode(filepath.Join(d.os.VarDir, "database"), freshHook, legacy) if err != nil { return nil, fmt.Errorf("Error creating database: %s", err) } return dump, nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/file_snapshot.go#L143-L205
func (f *FileSnapshotStore) Create(version SnapshotVersion, index, term uint64, configuration Configuration, configurationIndex uint64, trans Transport) (SnapshotSink, error) { // We only support version 1 snapshots at this time. if version != 1 { return nil, fmt.Errorf("unsupported snapshot version %d", version) } // Create a new path name := snapshotName(term, index) path := filepath.Join(f.path, name+tmpSuffix) f.logger.Printf("[INFO] snapshot: Creating new snapshot at %s", path) // Make the directory if err := os.MkdirAll(path, 0755); err != nil { f.logger.Printf("[ERR] snapshot: Failed to make snapshot directory: %v", err) return nil, err } // Create the sink sink := &FileSnapshotSink{ store: f, logger: f.logger, dir: path, parentDir: f.path, meta: fileSnapshotMeta{ SnapshotMeta: SnapshotMeta{ Version: version, ID: name, Index: index, Term: term, Peers: encodePeers(configuration, trans), Configuration: configuration, ConfigurationIndex: configurationIndex, }, CRC: nil, }, } // Write out the meta data if err := sink.writeMeta(); err != nil { f.logger.Printf("[ERR] snapshot: Failed to write metadata: %v", err) return nil, err } // Open the state file statePath := filepath.Join(path, stateFilePath) fh, err := os.Create(statePath) if err != nil { f.logger.Printf("[ERR] snapshot: Failed to create state file: %v", err) return nil, err } sink.stateFile = fh // Create a CRC64 hash sink.stateHash = crc64.New(crc64.MakeTable(crc64.ECMA)) // Wrap both the hash and file in a MultiWriter with buffering multi := io.MultiWriter(sink.stateFile, sink.stateHash) sink.buffered = bufio.NewWriter(multi) // Done return sink, nil }
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/dsl/pact.go#L280-L295
func (p *Pact) WritePact() error { p.Setup(true) log.Println("[DEBUG] pact write Pact file") mockServer := MockService{ BaseURL: fmt.Sprintf("http://%s:%d", p.Host, p.Server.Port), Consumer: p.Consumer, Provider: p.Provider, PactFileWriteMode: p.PactFileWriteMode, } err := mockServer.WritePact() if err != nil { return err } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/accessibility/types.go#L144-L162
func (t *ValueSourceType) UnmarshalEasyJSON(in *jlexer.Lexer) { switch ValueSourceType(in.String()) { case ValueSourceTypeAttribute: *t = ValueSourceTypeAttribute case ValueSourceTypeImplicit: *t = ValueSourceTypeImplicit case ValueSourceTypeStyle: *t = ValueSourceTypeStyle case ValueSourceTypeContents: *t = ValueSourceTypeContents case ValueSourceTypePlaceholder: *t = ValueSourceTypePlaceholder case ValueSourceTypeRelatedElement: *t = ValueSourceTypeRelatedElement default: in.AddError(errors.New("unknown ValueSourceType value")) } }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/goav2gen/api.go#L122-L163
func extractCmdLineParams(a *gen.ActionParam, root string, seen map[string]*[]*gen.ActionParam, parentNotMandatory bool) []*gen.ActionParam { switch t := a.Type.(type) { case *gen.BasicDataType, *gen.EnumerableDataType, *gen.UploadDataType: dup := gen.ActionParam{ Name: a.Name, QueryName: root, Description: a.Description, VarName: a.VarName, Location: a.Location, Type: a.Type, Mandatory: a.Mandatory && !parentNotMandatory, // yay for double negations! NonBlank: a.NonBlank, Regexp: a.Regexp, ValidValues: a.ValidValues, Min: a.Min, Max: a.Max, } return []*gen.ActionParam{&dup} case *gen.ArrayDataType: p := t.ElemType eq, ok := seen[p.Name] if !ok { eq = &[]*gen.ActionParam{} seen[p.Name] = eq *eq = extractCmdLineParams(p, root+"[]", seen, parentNotMandatory || !a.Mandatory) } return *eq case *gen.ObjectDataType: params := []*gen.ActionParam{} for _, f := range t.Fields { eq, ok := seen[f.Name] if !ok { eq = &[]*gen.ActionParam{} seen[f.Name] = eq *eq = extractCmdLineParams(f, fmt.Sprintf("%s[%s]", root, f.Name), seen, parentNotMandatory || !a.Mandatory) } params = append(params, *eq...) } return params } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/fakegithub/fakegithub.go#L450-L460
func (f *FakeClient) GetProjectColumns(projectID int) ([]github.ProjectColumn, error) { // Get project name for _, projects := range f.RepoProjects { for _, project := range projects { if projectID == project.ID { return f.ProjectColumnsMap[project.Name], nil } } } return nil, fmt.Errorf("Cannot find project ID") }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/spyglass/gcsartifact_fetcher.go#L188-L190
func (src *gcsJobSource) jobPath() string { return fmt.Sprintf("%s/%s", src.bucket, src.jobPrefix) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L5415-L5419
func (v AwaitPromiseReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime50(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L1976-L1980
func (v SearchInContentReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger20(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L1873-L1875
func (api *API) CloudAccountLocator(href string) *CloudAccountLocator { return &CloudAccountLocator{Href(href), api} }
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/snowballword/snowballword.go#L283-L289
func (w *SnowballWord) RemoveFirstSuffixIfIn(startPos int, suffixes ...string) (suffix string, suffixRunes []rune) { suffix, suffixRunes = w.FirstSuffixIfIn(startPos, len(w.RS), suffixes...) if suffix != "" { w.RemoveLastNRunes(len(suffixRunes)) } return }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L1167-L1170
func (p ResolveNodeParams) WithNodeID(nodeID cdp.NodeID) *ResolveNodeParams { p.NodeID = nodeID return &p }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/page.go#L355-L360
func (p *Page) SwitchToRootFrame() error { if err := p.session.Frame(nil); err != nil { return fmt.Errorf("failed to switch to original page frame: %s", err) } return nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/lex/case.go#L29-L72
func Snake(name string) string { var ret bytes.Buffer multipleUpper := false var lastUpper rune var beforeUpper rune for _, c := range name { // Non-lowercase character after uppercase is considered to be uppercase too. isUpper := (unicode.IsUpper(c) || (lastUpper != 0 && !unicode.IsLower(c))) if lastUpper != 0 { // Output a delimiter if last character was either the // first uppercase character in a row, or the last one // in a row (e.g. 'S' in "HTTPServer"). Do not output // a delimiter at the beginning of the name. firstInRow := !multipleUpper lastInRow := !isUpper if ret.Len() > 0 && (firstInRow || lastInRow) && beforeUpper != '_' { ret.WriteByte('_') } ret.WriteRune(unicode.ToLower(lastUpper)) } // Buffer uppercase char, do not output it yet as a delimiter // may be required if the next character is lowercase. if isUpper { multipleUpper = (lastUpper != 0) lastUpper = c continue } ret.WriteRune(c) lastUpper = 0 beforeUpper = c multipleUpper = false } if lastUpper != 0 { ret.WriteRune(unicode.ToLower(lastUpper)) } return string(ret.Bytes()) }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L5651-L5654
func (e LedgerEntryChangeType) ValidEnum(v int32) bool { _, ok := ledgerEntryChangeTypeMap[v] return ok }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/app/app.go#L335-L346
func ReleaseApplicationLock(appName string) { var err error retries := 3 for i := 0; i < retries; i++ { err = releaseApplicationLockOnce(appName) if err == nil { return } time.Sleep(time.Second * time.Duration(i+1)) } log.Error(err) }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ca/cac/codegen_client.go#L3953-L4039
func (loc *UserSettingLocator) Update(options rsapi.APIParams) (*UserSetting, error) { var res *UserSetting var params rsapi.APIParams params = rsapi.APIParams{} var viewOpt = options["view"] if viewOpt != nil { params["view"] = viewOpt } var p rsapi.APIParams p = rsapi.APIParams{} var dateRangeOpt = options["date_range"] if dateRangeOpt != nil { p["date_range"] = dateRangeOpt } var dismissedDialogsOpt = options["dismissed_dialogs"] if dismissedDialogsOpt != nil { p["dismissed_dialogs"] = dismissedDialogsOpt } var excludedTagTypesOpt = options["excluded_tag_types"] if excludedTagTypesOpt != nil { p["excluded_tag_types"] = excludedTagTypesOpt } var filtersOpt = options["filters"] if filtersOpt != nil { p["filters"] = filtersOpt } var granularityOpt = options["granularity"] if granularityOpt != nil { p["granularity"] = granularityOpt } var mainMenuVisibilityOpt = options["main_menu_visibility"] if mainMenuVisibilityOpt != nil { p["main_menu_visibility"] = mainMenuVisibilityOpt } var metricsOpt = options["metrics"] if metricsOpt != nil { p["metrics"] = metricsOpt } var moduleStatesOpt = options["module_states"] if moduleStatesOpt != nil { p["module_states"] = moduleStatesOpt } var onboardingStatusOpt = options["onboarding_status"] if onboardingStatusOpt != nil { p["onboarding_status"] = onboardingStatusOpt } var selectedCloudVendorNamesOpt = options["selected_cloud_vendor_names"] if selectedCloudVendorNamesOpt != nil { p["selected_cloud_vendor_names"] = selectedCloudVendorNamesOpt } var sortingOpt = options["sorting"] if sortingOpt != nil { p["sorting"] = sortingOpt } var tableColumnVisibilityOpt = options["table_column_visibility"] if tableColumnVisibilityOpt != nil { p["table_column_visibility"] = tableColumnVisibilityOpt } uri, err := loc.ActionPath("UserSetting", "update") if err != nil { return res, err } req, err := loc.api.BuildHTTPRequest(uri.HTTPMethod, uri.Path, APIVersion, params, p) if err != nil { return res, err } resp, err := loc.api.PerformRequest(req) if err != nil { return res, err } defer resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode > 299 { respBody, _ := ioutil.ReadAll(resp.Body) sr := string(respBody) if sr != "" { sr = ": " + sr } return res, fmt.Errorf("invalid response %s%s", resp.Status, sr) } defer resp.Body.Close() respBody, err := ioutil.ReadAll(resp.Body) if err != nil { return res, err } err = json.Unmarshal(respBody, &res) return res, err }
https://github.com/mikespook/possum/blob/56d7ebb6470b670001632b11be7fc089038f4dd7/helper.go#L59-L62
func WebSocketHandlerFunc(f func(ws *websocket.Conn)) HandlerFunc { h := websocket.Handler(f) return WrapHTTPHandlerFunc(h.ServeHTTP) }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/account_merge.go#L50-L52
func (m Destination) MutateAccountMerge(o *AccountMergeBuilder) error { return setAccountId(m.AddressOrSeed, &o.Destination) }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/flame/models.go#L131-L164
func (a *Application) Validate() error { // hash password if available err := a.HashSecret() if err != nil { return err } // check id if !a.ID().Valid() { return fire.E("invalid id") } // check name if a.Name == "" { return fire.E("name not set") } // check key if a.Key == "" { return fire.E("key not set") } // check secret hash if len(a.SecretHash) == 0 { return fire.E("secret hash not set") } // check redirect uri if a.RedirectURL != "" && !govalidator.IsURL(a.RedirectURL) { return fire.E("invalid redirect url") } return nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/config/map.go#L40-L88
func (m *Map) Change(changes map[string]interface{}) (map[string]string, error) { values := make(map[string]string, len(m.schema)) errors := ErrorList{} for name, change := range changes { key, ok := m.schema[name] // When a hidden value is set to "true" in the change set, it // means "keep it unchanged", so we replace it with our current // value. if ok && key.Hidden && change == true { change = m.GetRaw(name) } // A nil object means the empty string. if change == nil { change = "" } // Sanity check that we were actually passed a string. s := reflect.ValueOf(change) if s.Kind() != reflect.String { errors.add(name, nil, fmt.Sprintf("invalid type %s", s.Kind())) continue } values[name] = change.(string) } if errors.Len() > 0 { return nil, errors } // Any key not explicitly set, is considered unset. for name, key := range m.schema { _, ok := values[name] if !ok { values[name] = key.Default } } names, err := m.update(values) changed := map[string]string{} for _, name := range names { changed[name] = m.GetRaw(name) } return changed, err }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/image/memory.go#L42-L51
func (i *memoryImage) Manifest(ctx context.Context) ([]byte, string, error) { if i.serializedManifest == nil { m, err := i.genericManifest.serialize() if err != nil { return nil, "", err } i.serializedManifest = m } return i.serializedManifest, i.genericManifest.manifestMIMEType(), nil }
https://github.com/bsm/sarama-cluster/blob/d5779253526cc8a3129a0e5d7cc429f4b4473ab4/consumer.go#L512-L534
func (c *Consumer) release() (err error) { // Stop all consumers c.subs.Stop() // Clear subscriptions on exit defer c.subs.Clear() // Wait for messages to be processed timeout := time.NewTimer(c.client.config.Group.Offsets.Synchronization.DwellTime) defer timeout.Stop() select { case <-c.dying: case <-timeout.C: } // Commit offsets, continue on errors if e := c.commitOffsetsWithRetry(c.client.config.Group.Offsets.Retry.Max); e != nil { err = e } return }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/layertree/easyjson.go#L243-L247
func (v *SnapshotCommandLogReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoLayertree1(&r, v) return r.Error() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/type_filter_wrapper.go#L41-L46
func NewTypeFilterWrapperPlugin(plugin Plugin) *TypeFilterWrapperPlugin { return &TypeFilterWrapperPlugin{ plugin: plugin, pass: map[string]bool{}, } }
https://github.com/onsi/gomega/blob/f0e010e04c08c48a875f83d17df37b04eb3a985b/gbytes/io_wrappers.go#L18-L20
func TimeoutReader(r io.Reader, timeout time.Duration) io.Reader { return timeoutReaderWriterCloser{r: r, d: timeout} }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L128-L140
func NewPublicKey(aType CryptoKeyType, value interface{}) (result PublicKey, err error) { result.Type = aType switch CryptoKeyType(aType) { case CryptoKeyTypeKeyTypeEd25519: tv, ok := value.(Uint256) if !ok { err = fmt.Errorf("invalid value, must be Uint256") return } result.Ed25519 = &tv } return }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L9143-L9145
func (api *API) RightScriptLocator(href string) *RightScriptLocator { return &RightScriptLocator{Href(href), api} }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L6293-L6297
func (v CreateStyleSheetReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoCss58(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/mrd0ll4r/tbotapi/blob/edc257282178bb5cebbfcc41260ec04c1ec7ac19/outgoing.go#L648-L657
func NewInlineQueryResultGif(id, gifURL, thumbURL string) *InlineQueryResultGif { return &InlineQueryResultGif{ InlineQueryResultBase: InlineQueryResultBase{ Type: GifResult, ID: id, }, GifURL: gifURL, ThumbURL: thumbURL, } }
https://github.com/rsc/pdf/blob/c47d69cf462f804ff58ca63c61a8fb2aed76587e/lex.go#L52-L60
func newBuffer(r io.Reader, offset int64) *buffer { return &buffer{ r: r, offset: offset, buf: make([]byte, 0, 4096), allowObjptr: true, allowStream: true, } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/types.go#L422-L424
func (t *Subtype) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) }
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/dsl/client.go#L349-L366
func getPort(rawURL string) int { parsedURL, err := url.Parse(rawURL) if err == nil { splitHost := strings.Split(parsedURL.Host, ":") if len(splitHost) == 2 { port, err := strconv.Atoi(splitHost[1]) if err == nil { return port } } if parsedURL.Scheme == "https" { return 443 } return 80 } return -1 }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L941-L953
func InitFont(fontFace int, hscale, vscale, shear float32, thickness, lineType int) *Font { font := new(Font) C.cvInitFont( &font.font, C.int(fontFace), C.double(hscale), C.double(vscale), C.double(shear), C.int(thickness), C.int(lineType), ) return font }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/group.go#L65-L82
func (g *Group) Handle(name string, a *GroupAction) { if name == "" { panic(fmt.Sprintf(`fire: invalid group action "%s"`, name)) } // set default body limit if a.Action.BodyLimit == 0 { a.Action.BodyLimit = DataSize("8M") } // check existence if g.actions[name] != nil { panic(fmt.Sprintf(`fire: action with name "%s" already exists`, name)) } // add action g.actions[name] = a }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/tracing/easyjson.go#L1104-L1108
func (v EventBufferUsage) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoTracing10(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pfs/s3/error.go#L57-L59
func invalidDelimiterError(w http.ResponseWriter, r *http.Request) { writeError(w, r, http.StatusBadRequest, "InvalidDelimiter", "The delimiter you specified is invalid. It must be '' or '/'.") }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/client/routes/patch_apps_app_routes_route_parameters.go#L144-L147
func (o *PatchAppsAppRoutesRouteParams) WithRoute(route string) *PatchAppsAppRoutesRouteParams { o.SetRoute(route) return o }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/commitment.go#L50-L61
func (c *commitment) setConfiguration(configuration Configuration) { c.Lock() defer c.Unlock() oldMatchIndexes := c.matchIndexes c.matchIndexes = make(map[ServerID]uint64) for _, server := range configuration.Servers { if server.Suffrage == Voter { c.matchIndexes[server.ID] = oldMatchIndexes[server.ID] // defaults to 0 } } c.recalculate() }
https://github.com/aphistic/gomol/blob/1546845ba714699f76f484ad3af64cf0503064d1/log_adapter.go#L249-L251
func (la *LogAdapter) Fatal(msg string) error { return la.Log(LevelFatal, nil, msg) }
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/builder.go#L78-L81
func (p MailBuilder) CC(name, addr string) MailBuilder { p.cc = append(p.cc, mail.Address{Name: name, Address: addr}) return p }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/common/mason_config.go#L71-L77
func (t TypeToResources) Copy() TypeToResources { n := TypeToResources{} for k, v := range t { n[k] = v } return n }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/backgroundservice/easyjson.go#L83-L87
func (v *StopObservingParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoBackgroundservice(&r, v) return r.Error() }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L685-L687
func Subtract(src1, src2, dst *IplImage) { SubtractWithMask(src1, src2, dst, nil) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/animation/easyjson.go#L395-L399
func (v SeekAnimationsParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoAnimation3(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/selectable.go#L146-L148
func (s *selectable) All(selector string) *MultiSelection { return newMultiSelection(s.session, s.selectors.Append(target.CSS, selector)) }
https://github.com/go-bongo/bongo/blob/761759e31d8fed917377aa7085db01d218ce50d8/main.go#L39-L71
func (m *Connection) Connect() (err error) { defer func() { if r := recover(); r != nil { // panic(r) // return if e, ok := r.(error); ok { err = e } else if e, ok := r.(string); ok { err = errors.New(e) } else { err = errors.New(fmt.Sprint(r)) } } }() if m.Config.DialInfo == nil { if m.Config.DialInfo, err = mgo.ParseURL(m.Config.ConnectionString); err != nil { panic(fmt.Sprintf("cannot parse given URI %s due to error: %s", m.Config.ConnectionString, err.Error())) } } session, err := mgo.DialWithInfo(m.Config.DialInfo) if err != nil { return err } m.Session = session m.Session.SetMode(mgo.Monotonic, true) return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L117-L121
func (v StepOutParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger1(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L3646-L3660
func NewInflationResult(code InflationResultCode, value interface{}) (result InflationResult, err error) { result.Code = code switch InflationResultCode(code) { case InflationResultCodeInflationSuccess: tv, ok := value.([]InflationPayout) if !ok { err = fmt.Errorf("invalid value, must be []InflationPayout") return } result.Payouts = &tv default: // void } return }
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/object.go#L241-L246
func (p *Process) Type(x Object) (*Type, int64) { p.typeHeap() i, _ := p.findObjectIndex(core.Address(x)) return p.types[i].t, p.types[i].r }
https://github.com/texttheater/golang-levenshtein/blob/d188e65d659ef53fcdb0691c12f1bba64928b649/levenshtein/levenshtein.go#L213-L215
func LogMatrix(source []rune, target []rune, matrix [][]int) { WriteMatrix(source, target, matrix, os.Stderr) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/collection/transaction.go#L76-L79
func newSTMRepeatable(ctx context.Context, c *v3.Client, apply func(STM) error) (*v3.TxnResponse, error) { s := &stm{client: c, ctx: ctx, getOpts: []v3.OpOption{v3.WithSerializable()}} return runSTM(s, apply, false) }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/docker_transport.go#L29-L31
func (t dockerTransport) ParseReference(reference string) (types.ImageReference, error) { return ParseReference(reference) }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/cmd/autogazelle/server_unix.go#L239-L243
func recordWrite(path string) { dirSetMutex.Lock() defer dirSetMutex.Unlock() dirSet[path] = true }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/change_trust.go#L61-L64
func (m Limit) MutateChangeTrust(o *xdr.ChangeTrustOp) (err error) { o.Limit, err = amount.Parse(string(m)) return }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cancel/canceler.go#L16-L24
func NewCanceler() *Canceler { c := Canceler{} c.lock.Lock() c.reqChCancel = make(map[*http.Request]chan struct{}) c.lock.Unlock() return &c }
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/cmd/seqinfo/seqinfo.go#L204-L294
func parse(pattern string, opts *OptionsType) *Result { res := &Result{String: pattern, origString: pattern} padStyle := fileseq.PadStyleHash4 if opts.Hash1 { padStyle = fileseq.PadStyleHash1 } fs, err := fileseq.NewFileSequencePad(pattern, padStyle) if err != nil { res.Error = err.Error() return res } // Handle any of the optional modifications to the seq if opts.Format != "" { refmt, err := fs.Format(opts.Format) if err != nil { res.Error = err.Error() return res } fs, err = fileseq.NewFileSequencePad(refmt, padStyle) if err != nil { res.Error = err.Error() return res } } if opts.Dirname != "" { fs.SetDirname(opts.Dirname) } if opts.Basename != "" { fs.SetBasename(opts.Basename) } if opts.Ext != "" { fs.SetExt(opts.Ext) } if opts.Padding != "" { fs.SetPadding(opts.Padding) } if opts.Range != "" { if err := fs.SetFrameRange(opts.Range); err != nil { res.Error = err.Error() return res } } if opts.Inverted { frange := fs.InvertedFrameRange() if frange != "" { _ = fs.SetFrameRange(frange) } else { fs.SetFrameSet(nil) } } if opts.Index != nil { frame := fs.Index(*opts.Index) if frame == "" { res.Error = fmt.Sprintf("Index %d out of range %q", *opts.Index, fs.FrameRange()) return res } fs, _ = fileseq.NewFileSequencePad(frame, padStyle) _ = fs.SetFrameRange(strconv.Itoa(fs.Start())) } if opts.Frame != nil { frame, _ := fs.Frame(*opts.Frame) fs, _ = fileseq.NewFileSequencePad(frame, padStyle) _ = fs.SetFrameRange(strconv.Itoa(fs.Start())) } // Final setting of results res.String = fs.String() res.Dirname = fs.Dirname() res.Basename = fs.Basename() res.Ext = fs.Ext() res.Start = fs.Start() res.End = fs.End() res.Len = fs.Len() res.Padding = fs.Padding() res.ZFill = fs.ZFill() res.Range = fs.FrameRange() res.HasRange = (fs.FrameSet() != nil) return res }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/balancer/resolver/endpoint/endpoint.go#L98-L100
func Target(id, endpoint string) string { return fmt.Sprintf("%s://%s/%s", scheme, id, endpoint) }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/access_barrier.go#L158-L176
func (ab *AccessBarrier) Release(bs *BarrierSession) { if ab.active { liveCount := atomic.AddInt32(bs.liveCount, -1) if liveCount == barrierFlushOffset { buf := ab.freeq.MakeBuf() defer ab.freeq.FreeBuf(buf) // Accessors which entered a closed barrier session steps down automatically // But, they may try to close an already closed session. if atomic.AddInt32(&bs.closed, 1) == 1 { ab.freeq.Insert(unsafe.Pointer(bs), CompareBS, buf, &ab.freeq.Stats) if atomic.CompareAndSwapInt32(&ab.isDestructorRunning, 0, 1) { ab.doCleanup() atomic.CompareAndSwapInt32(&ab.isDestructorRunning, 1, 0) } } } } }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L209-L214
func CreateMatHeader(rows, cols, type_ int) *Mat { mat := C.cvCreateMatHeader( C.int(rows), C.int(cols), C.int(type_), ) return (*Mat)(mat) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/replication.go#L504-L528
func (r *Raft) setPreviousLog(req *AppendEntriesRequest, nextIndex uint64) error { // Guard for the first index, since there is no 0 log entry // Guard against the previous index being a snapshot as well lastSnapIdx, lastSnapTerm := r.getLastSnapshot() if nextIndex == 1 { req.PrevLogEntry = 0 req.PrevLogTerm = 0 } else if (nextIndex - 1) == lastSnapIdx { req.PrevLogEntry = lastSnapIdx req.PrevLogTerm = lastSnapTerm } else { var l Log if err := r.logs.GetLog(nextIndex-1, &l); err != nil { r.logger.Error(fmt.Sprintf("Failed to get log at index %d: %v", nextIndex-1, err)) return err } // Set the previous index and term (0 if nextIndex is 1) req.PrevLogEntry = l.Index req.PrevLogTerm = l.Term } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/boskos.go#L101-L114
func ErrorToStatus(err error) int { switch err.(type) { default: return http.StatusInternalServerError case *ranch.OwnerNotMatch: return http.StatusUnauthorized case *ranch.ResourceNotFound: return http.StatusNotFound case *ranch.ResourceTypeNotFound: return http.StatusNotFound case *ranch.StateNotMatch: return http.StatusConflict } }
https://github.com/nwaples/rardecode/blob/197ef08ef68c4454ae5970a9c2692d6056ceb8d7/ppm_model.go#L350-L370
func (a *subAllocator) pushByte(c byte) int32 { si := a.heap1Lo / 6 // state index oi := a.heap1Lo % 6 // byte position in state switch oi { case 0: a.states[si].sym = c case 1: a.states[si].freq = c default: n := (uint(oi) - 2) * 8 mask := ^(uint32(0xFF) << n) succ := uint32(a.states[si].succ) & mask succ |= uint32(c) << n a.states[si].succ = int32(succ) } a.heap1Lo++ if a.heap1Lo >= a.heap1Hi { return 0 } return -a.heap1Lo }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/storage/storage_reference.go#L56-L119
func (s *storageReference) resolveImage() (*storage.Image, error) { var loadedImage *storage.Image if s.id == "" && s.named != nil { // Look for an image that has the expanded reference name as an explicit Name value. image, err := s.transport.store.Image(s.named.String()) if image != nil && err == nil { loadedImage = image s.id = image.ID } } if s.id == "" && s.named != nil { if digested, ok := s.named.(reference.Digested); ok { // Look for an image with the specified digest that has the same name, // though possibly with a different tag or digest, as a Name value, so // that the canonical reference can be implicitly resolved to the image. images, err := s.transport.store.ImagesByDigest(digested.Digest()) if err == nil && len(images) > 0 { for _, image := range images { if imageMatchesRepo(image, s.named) { loadedImage = image s.id = image.ID break } } } } } if s.id == "" { logrus.Debugf("reference %q does not resolve to an image ID", s.StringWithinTransport()) return nil, errors.Wrapf(ErrNoSuchImage, "reference %q does not resolve to an image ID", s.StringWithinTransport()) } if loadedImage == nil { img, err := s.transport.store.Image(s.id) if err != nil { return nil, errors.Wrapf(err, "error reading image %q", s.id) } loadedImage = img } if s.named != nil { if !imageMatchesRepo(loadedImage, s.named) { logrus.Errorf("no image matching reference %q found", s.StringWithinTransport()) return nil, ErrNoSuchImage } } // Default to having the image digest that we hand back match the most recently // added manifest... if digest, ok := loadedImage.BigDataDigests[storage.ImageDigestBigDataKey]; ok { loadedImage.Digest = digest } // ... unless the named reference says otherwise, and it matches one of the digests // in the image. For those cases, set the Digest field to that value, for the // sake of older consumers that don't know there's a whole list in there now. if s.named != nil { if digested, ok := s.named.(reference.Digested); ok { for _, digest := range loadedImage.Digests { if digest == digested.Digest() { loadedImage.Digest = digest break } } } } return loadedImage, nil }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/signature/policy_eval.go#L97-L103
func (pc *PolicyContext) changeState(expected, new policyContextState) error { if pc.state != expected { return errors.Errorf(`"Invalid PolicyContext state, expected "%s", found "%s"`, expected, pc.state) } pc.state = new return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/lease_command.go#L56-L73
func leaseGrantCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("lease grant command needs TTL argument")) } ttl, err := strconv.ParseInt(args[0], 10, 64) if err != nil { ExitWithError(ExitBadArgs, fmt.Errorf("bad TTL (%v)", err)) } ctx, cancel := commandCtx(cmd) resp, err := mustClientFromCmd(cmd).Grant(ctx, ttl) cancel() if err != nil { ExitWithError(ExitError, fmt.Errorf("failed to grant lease (%v)", err)) } display.Grant(*resp) }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/benchmark/tcp_frame_relay.go#L36-L46
func NewTCPFrameRelay(dests []string, modifier func(bool, *tchannel.Frame) *tchannel.Frame) (Relay, error) { var err error r := &tcpFrameRelay{modifier: modifier} r.tcpRelay, err = newTCPRelay(dests, r.handleConnFrameRelay) if err != nil { return nil, err } return r, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/accessibility/accessibility.go#L106-L115
func (p *GetPartialAXTreeParams) Do(ctx context.Context) (nodes []*Node, err error) { // execute var res GetPartialAXTreeReturns err = cdp.Execute(ctx, CommandGetPartialAXTree, p, &res) if err != nil { return nil, err } return res.Nodes, nil }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/skiplist/iterator.go#L28-L37
func (s *Skiplist) NewIterator(cmp CompareFn, buf *ActionBuffer) *Iterator { return &Iterator{ cmp: cmp, s: s, buf: buf, bs: s.barrier.Acquire(), } }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L4606-L4608
func (api *API) InstanceTypeLocator(href string) *InstanceTypeLocator { return &InstanceTypeLocator{Href(href), api} }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/cmdutil/cobra.go#L82-L92
func ParseCommits(args []string) ([]*pfs.Commit, error) { var results []*pfs.Commit for _, arg := range args { commit, err := ParseCommit(arg) if err != nil { return nil, err } results = append(results, commit) } return results, nil }