_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/influx.go#L134-L144
func (i *InfluxDB) Push(tags map[string]string, fields map[string]interface{}, date time.Time) error { pt, err := influxdb.NewPoint(i.measurement, mergeTags(i.tags, tags), fields, date) if err != nil { return err } i.batch.AddPoint(pt) i.batchSize++ return nil }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6610-L6619
func (u StellarMessage) GetTxSetHash() (result Uint256, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) if armName == "TxSetHash" { result = *u.TxSetHash ok = true } return }
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/firewallrule.go#L45-L50
func (c *Client) ListFirewallRules(dcID string, serverID string, nicID string) (*FirewallRules, error) { url := fwruleColPath(dcID, serverID, nicID) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &FirewallRules{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L498-L504
func (s *UniIterator) Seek(key []byte) { if !s.reversed { s.iter.Seek(key) } else { s.iter.SeekForPrev(key) } }
https://github.com/tendermint/go-amino/blob/dc14acf9ef15f85828bfbc561ed9dd9d2a284885/binary-decode.go#L862-L888
func DecodeDisambPrefixBytes(bz []byte) (db DisambBytes, hasDb bool, pb PrefixBytes, hasPb bool, n int, err error) { // Validate if len(bz) < 4 { err = errors.New("EOF while reading prefix bytes.") return // hasPb = false } if bz[0] == 0x00 { // Disfix // Validate if len(bz) < 8 { err = errors.New("EOF while reading disamb bytes.") return // hasPb = false } copy(db[0:3], bz[1:4]) copy(pb[0:4], bz[4:8]) hasDb = true hasPb = true n = 8 return } else { // Prefix // General case with no disambiguation copy(pb[0:4], bz[0:4]) hasDb = false hasPb = true n = 4 return } }
https://github.com/weaveworks/mesh/blob/512bdb7b3cb7b2c939fcd0ee434d48b6732ecc39/protocol_crypto.go#L126-L132
func (sender *encryptedTCPSender) Send(msg []byte) error { sender.Lock() defer sender.Unlock() encodedMsg := secretbox.Seal(nil, msg, &sender.state.nonce, sender.state.sessionKey) sender.state.advance() return sender.sender.Send(encodedMsg) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/require-matching-label/require-matching-label.go#L143-L163
func matchingConfigs(org, repo, branch, label string, allConfigs []plugins.RequireMatchingLabel) []plugins.RequireMatchingLabel { var filtered []plugins.RequireMatchingLabel for _, cfg := range allConfigs { // Check if the config applies to this issue type. if (branch == "" && !cfg.Issues) || (branch != "" && !cfg.PRs) { continue } // Check if the config applies to this 'org[/repo][/branch]'. if org != cfg.Org || (cfg.Repo != "" && cfg.Repo != repo) || (cfg.Branch != "" && branch != "" && cfg.Branch != branch) { continue } // If we are reacting to a label event, see if it is relevant. if label != "" && !cfg.Re.MatchString(label) { continue } filtered = append(filtered, cfg) } return filtered }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/sql/mysql.go#L50-L66
func (config *MySQLConfig) CreateDatabase() (*gorm.DB, error) { db, err := gorm.Open("mysql", config.getDSN("")) if err != nil { return nil, err } db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %v;", config.Db)) db.Close() db, err = gorm.Open("mysql", config.getDSN(config.Db)) err = db.AutoMigrate(&Assignee{}, &Issue{}, &IssueEvent{}, &Label{}, &Comment{}).Error if err != nil { return nil, err } return db, nil }
https://github.com/coryb/figtree/blob/e5fa026ccd54e0a6a99b6d81f73bfcc8e6fe6a6b/gen-rawoption.go#L2931-L2940
func (o *MapRuneOption) Set(value string) error { parts := stringMapRegex.Split(value, 2) if len(parts) != 2 { return fmt.Errorf("expected KEY=VALUE got '%s'", value) } val := RuneOption{} val.Set(parts[1]) (*o)[parts[0]] = val return nil }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/lookaside.go#L180-L190
func (ns registryNamespace) signatureTopLevel(write bool) string { if write && ns.SigStoreStaging != "" { logrus.Debugf(` Using %s`, ns.SigStoreStaging) return ns.SigStoreStaging } if ns.SigStore != "" { logrus.Debugf(` Using %s`, ns.SigStore) return ns.SigStore } return "" }
https://github.com/google/go-cmp/blob/6f77996f0c42f7b84e5a2b252227263f93432e9b/cmp/report_slices.go#L287-L309
func coalesceAdjacentEdits(name string, es diff.EditScript) (groups []diffStats) { var prevCase int // Arbitrary index into which case last occurred lastStats := func(i int) *diffStats { if prevCase != i { groups = append(groups, diffStats{Name: name}) prevCase = i } return &groups[len(groups)-1] } for _, e := range es { switch e { case diff.Identity: lastStats(1).NumIdentical++ case diff.UniqueX: lastStats(2).NumRemoved++ case diff.UniqueY: lastStats(2).NumInserted++ case diff.Modified: lastStats(2).NumModified++ } } return groups }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/version/api.go#L157-L173
func APIExtensionsCount() int { count := len(APIExtensions) // This environment variable is an internal one to force the code // to believe that we an API extensions version greater than we // actually have. It's used by integration tests to exercise the // cluster upgrade process. artificialBump := os.Getenv("LXD_ARTIFICIALLY_BUMP_API_EXTENSIONS") if artificialBump != "" { n, err := strconv.Atoi(artificialBump) if err == nil { count += n } } return count }
https://github.com/kljensen/snowball/blob/115fa8f6419dcfb9ec4653997b1c6803a5eff962/russian/step4.go#L10-L38
func step4(word *snowballword.SnowballWord) bool { // (1) Undouble "н", or, 2) if the word ends with a SUPERLATIVE ending, // (remove it and undouble н n), or 3) if the word ends ь (') (soft sign) // remove it. // Undouble "н" if word.HasSuffixRunes([]rune("нн")) { word.RemoveLastNRunes(1) return true } // Remove superlative endings suffix, _ := word.RemoveFirstSuffix("ейше", "ейш") if suffix != "" { // Undouble "н" if word.HasSuffixRunes([]rune("нн")) { word.RemoveLastNRunes(1) } return true } // Remove soft sign if rsLen := len(word.RS); rsLen > 0 && word.RS[rsLen-1] == 'ь' { word.RemoveLastNRunes(1) return true } return false }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/runtime.go#L206-L212
func CompileScript(expression string, sourceURL string, persistScript bool) *CompileScriptParams { return &CompileScriptParams{ Expression: expression, SourceURL: sourceURL, PersistScript: persistScript, } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/lex.go#L41-L50
func stmtCodeVar(entity string, kind string, filters ...string) string { name := fmt.Sprintf("%s%s", entity, lex.Camel(kind)) if len(filters) > 0 { name += "By" name += strings.Join(filters, "And") } return name }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/net_transport.go#L221-L225
func (n *NetworkTransport) SetHeartbeatHandler(cb func(rpc RPC)) { n.heartbeatFnLock.Lock() defer n.heartbeatFnLock.Unlock() n.heartbeatFn = cb }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/build/controller.go#L607-L614
func injectEnvironment(b *buildv1alpha1.Build, rawEnv map[string]string) { for i := range b.Spec.Steps { // Inject environment variables to each step defaultEnv(&b.Spec.Steps[i], rawEnv) } if b.Spec.Template != nil { // Also add it as template arguments defaultArguments(b.Spec.Template, rawEnv) } }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/rsapi/auth.go#L66-L68
func NewTokenAuthenticator(token string, accountID int) Authenticator { return &tokenAuthenticator{token: token, accountID: accountID} }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/operation.go#L16-L19
func (m SourceAccount) MutateOperation(o *xdr.Operation) error { o.SourceAccount = &xdr.AccountId{} return setAccountId(m.AddressOrSeed, o.SourceAccount) }
https://github.com/aphistic/gomol/blob/1546845ba714699f76f484ad3af64cf0503064d1/base.go#L227-L243
func (b *Base) InitLoggers() error { if b.queue == nil { b.queue = newQueue(b, b.config.MaxQueueSize) } for _, logger := range b.loggers { err := logger.InitLogger() if err != nil { return err } } b.queue.startWorker() b.isInitialized = true return nil }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L1579-L1581
func (api *API) ChildAccountLocator(href string) *ChildAccountLocator { return &ChildAccountLocator{Href(href), api} }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/animation/easyjson.go#L292-L296
func (v *SetPausedParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoAnimation2(&r, v) return r.Error() }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/assets/assets.go#L362-L374
func GetBackendSecretVolumeAndMount(backend string) (v1.Volume, v1.VolumeMount) { return v1.Volume{ Name: client.StorageSecretName, VolumeSource: v1.VolumeSource{ Secret: &v1.SecretVolumeSource{ SecretName: client.StorageSecretName, }, }, }, v1.VolumeMount{ Name: client.StorageSecretName, MountPath: "/" + client.StorageSecretName, } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L726-L730
func (v *SetProduceCompilationCacheParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage7(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/systeminfo/easyjson.go#L392-L396
func (v *GetInfoReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoSysteminfo3(&r, v) return r.Error() }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/data_types.go#L418-L436
func MakeUniq(base string, taken []string) string { idx := 1 uniq := base inuse := true for inuse { inuse = false for _, gn := range taken { if gn == uniq { inuse = true break } } if inuse { idx++ uniq = base + strconv.Itoa(idx) } } return uniq }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/fileutil/fileutil.go#L62-L75
func CreateDirAll(dir string) error { err := TouchDirAll(dir) if err == nil { var ns []string ns, err = ReadDir(dir) if err != nil { return err } if len(ns) != 0 { err = fmt.Errorf("expected %q to be empty, got %q", dir, ns) } } return err }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/require/require.go#L82-L170
func ElementsEqualOrErr(expecteds interface{}, actuals interface{}) error { es := reflect.ValueOf(expecteds) as := reflect.ValueOf(actuals) // If either slice is empty, check that both are empty esIsEmpty := expecteds == nil || es.IsNil() || (es.Kind() == reflect.Slice && es.Len() == 0) asIsEmpty := actuals == nil || as.IsNil() || (as.Kind() == reflect.Slice && as.Len() == 0) if esIsEmpty && asIsEmpty { return nil } else if esIsEmpty { return fmt.Errorf("expected 0 elements, but got %d: %v", as.Len(), actuals) } else if asIsEmpty { return fmt.Errorf("expected %d elements, but got 0\n expected: %v", es.Len(), expecteds) } // Both slices are nonempty--compare elements if es.Kind() != reflect.Slice { return fmt.Errorf("\"expecteds\" must be a slice, but was %s", es.Type().String()) } if as.Kind() != reflect.Slice { return fmt.Errorf("\"actuals\" must be a slice, but was %s", as.Type().String()) } // Make sure expecteds and actuals are slices of the same type, modulo // pointers (*T ~= T in this function) esArePtrs := es.Type().Elem().Kind() == reflect.Ptr asArePtrs := as.Type().Elem().Kind() == reflect.Ptr esElemType, asElemType := es.Type().Elem(), as.Type().Elem() if esArePtrs { esElemType = es.Type().Elem().Elem() } if asArePtrs { asElemType = as.Type().Elem().Elem() } if esElemType != asElemType { return fmt.Errorf("Expected []%s but got []%s", es.Type().Elem(), as.Type().Elem()) } // Count up elements of expecteds intType := reflect.TypeOf(int64(0)) expectedCt := reflect.MakeMap(reflect.MapOf(esElemType, intType)) for i := 0; i < es.Len(); i++ { v := es.Index(i) if esArePtrs { v = v.Elem() } if !expectedCt.MapIndex(v).IsValid() { expectedCt.SetMapIndex(v, reflect.ValueOf(int64(1))) } else { newCt := expectedCt.MapIndex(v).Int() + 1 expectedCt.SetMapIndex(v, reflect.ValueOf(newCt)) } } // Count up elements of actuals actualCt := reflect.MakeMap(reflect.MapOf(asElemType, intType)) for i := 0; i < as.Len(); i++ { v := as.Index(i) if asArePtrs { v = v.Elem() } if !actualCt.MapIndex(v).IsValid() { actualCt.SetMapIndex(v, reflect.ValueOf(int64(1))) } else { newCt := actualCt.MapIndex(v).Int() + 1 actualCt.SetMapIndex(v, reflect.ValueOf(newCt)) } } if expectedCt.Len() != actualCt.Len() { // slight abuse of error: contains newlines so final output prints well return fmt.Errorf("expected %d distinct elements, but got %d\n expected: %v\n actual: %v", expectedCt.Len(), actualCt.Len(), expecteds, actuals) } for _, key := range expectedCt.MapKeys() { ec := expectedCt.MapIndex(key) ac := actualCt.MapIndex(key) if !ec.IsValid() || !ac.IsValid() || ec.Int() != ac.Int() { ecInt, acInt := int64(0), int64(0) if ec.IsValid() { ecInt = ec.Int() } if ac.IsValid() { acInt = ac.Int() } // slight abuse of error: contains newlines so final output prints well return fmt.Errorf("expected %d copies of %v, but got %d copies\n expected: %v\n actual: %v", ecInt, key, acInt, expecteds, actuals) } } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L2879-L2883
func (v *SearchInResponseBodyParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork21(&r, v) return r.Error() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/types.go#L539-L541
func (i Issue) IsAuthor(login string) bool { return NormLogin(i.User.Login) == NormLogin(login) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.mapper.go#L373-L383
func (c *ClusterTx) ContainerExists(project string, name string) (bool, error) { _, err := c.ContainerID(project, name) if err != nil { if err == ErrNoSuchObject { return false, nil } return false, err } return true, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/log/log.go#L99-L101
func (p *StopViolationsReportParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandStopViolationsReport, nil, nil) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/simplestreams_images.go#L42-L49
func (r *ProtocolSimpleStreams) GetImage(fingerprint string) (*api.Image, string, error) { image, err := r.ssClient.GetImage(fingerprint) if err != nil { return nil, "", err } return image, "", err }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/net_transport.go#L672-L682
func newNetPipeline(trans *NetworkTransport, conn *netConn) *netPipeline { n := &netPipeline{ conn: conn, trans: trans, doneCh: make(chan AppendFuture, rpcMaxPipeline), inprogressCh: make(chan *appendFuture, rpcMaxPipeline), shutdownCh: make(chan struct{}), } go n.decodeResponses() return n }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/response.go#L156-L161
func ForwardedResponse(client lxd.ContainerServer, request *http.Request) Response { return &forwardedResponse{ client: client, request: request, } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/containers.go#L1108-L1130
func (c *Cluster) ContainerBackupRename(oldName, newName string) error { err := c.Transaction(func(tx *ClusterTx) error { str := fmt.Sprintf("UPDATE containers_backups SET name = ? WHERE name = ?") stmt, err := tx.tx.Prepare(str) if err != nil { return err } defer stmt.Close() logger.Debug( "Calling SQL Query", log.Ctx{ "query": "UPDATE containers_backups SET name = ? WHERE name = ?", "oldName": oldName, "newName": newName}) if _, err := stmt.Exec(newName, oldName); err != nil { return err } return nil }) return err }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/thrift/server.go#L70-L84
func (s *Server) Register(svr TChanServer, opts ...RegisterOption) { service := svr.Service() handler := &handler{server: svr} for _, opt := range opts { opt.Apply(handler) } s.Lock() s.handlers[service] = *handler s.Unlock() for _, m := range svr.Methods() { s.ch.Register(s, service+"::"+m) } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/types.go#L73-L75
func (t *StyleSheetOrigin) UnmarshalJSON(buf []byte) error { return easyjson.Unmarshal(buf, t) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/debugger/easyjson.go#L812-L816
func (v SetPauseOnExceptionsParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDebugger8(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pluginhelp/hook/hook.go#L234-L262
func reversePluginMaps(config *plugins.Configuration, orgToRepos map[string]sets.String) (normal, external map[string][]string) { normal = map[string][]string{} for repo, enabledPlugins := range config.Plugins { var repos []string if !strings.Contains(repo, "/") { if flattened, ok := orgToRepos[repo]; ok { repos = flattened.List() } } else { repos = []string{repo} } for _, plugin := range enabledPlugins { normal[plugin] = append(normal[plugin], repos...) } } external = map[string][]string{} for repo, extPlugins := range config.ExternalPlugins { var repos []string if flattened, ok := orgToRepos[repo]; ok { repos = flattened.List() } else { repos = []string{repo} } for _, plugin := range extPlugins { external[plugin.Name] = append(external[plugin.Name], repos...) } } return }
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/core/process.go#L75-L88
func (p *Process) ReadableN(a Address, n int64) bool { for { m := p.findMapping(a) if m == nil || m.perm&Read == 0 { return false } c := m.max.Sub(a) if n <= c { return true } n -= c a = a.Add(c) } }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/event.go#L154-L173
func eventBlockList(w http.ResponseWriter, r *http.Request, t auth.Token) error { if !permission.Check(t, permission.PermEventBlockRead) { return permission.ErrUnauthorized } var active *bool if activeStr := InputValue(r, "active"); activeStr != "" { b, _ := strconv.ParseBool(activeStr) active = &b } blocks, err := event.ListBlocks(active) if err != nil { return err } if len(blocks) == 0 { w.WriteHeader(http.StatusNoContent) return nil } w.Header().Add("Content-Type", "application/json") return json.NewEncoder(w).Encode(blocks) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/memory/easyjson.go#L746-L750
func (v Module) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoMemory7(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/embed/serve.go#L385-L390
func WrapCORS(cors map[string]struct{}, h http.Handler) http.Handler { return &corsHandler{ ac: &etcdserver.AccessController{CORS: cors}, h: h, } }
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcawsprovisioner/tcawsprovisioner.go#L220-L223
func (awsProvisioner *AwsProvisioner) WorkerType_SignedURL(workerType string, duration time.Duration) (*url.URL, error) { cd := tcclient.Client(*awsProvisioner) return (&cd).SignedURL("/worker-type/"+url.QueryEscape(workerType), nil, duration) }
https://github.com/pivotal-pez/pezdispenser/blob/768e2777520868857916b66cfd4cfb7149383ca5/fakes/fake.go#L98-L100
func (s *FakeSku) New(tm skurepo.TaskManager, procurementMeta map[string]interface{}) skurepo.Sku { return s }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/socket/socket_classic.go#L29-L31
func Dial(ctx context.Context, protocol, addr string) (*Conn, error) { return DialTimeout(ctx, protocol, addr, 0) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/backoff/ticker.go#L24-L35
func NewTicker(b BackOff) *Ticker { c := make(chan time.Time) t := &Ticker{ C: c, c: c, b: b, stop: make(chan struct{}), } go t.run() runtime.SetFinalizer(t, (*Ticker).Stop) return t }
https://github.com/r3labs/sse/blob/2f90368216802092e9ed520c43e974e11d50438d/event_log.go#L28-L34
func (e *EventLog) Replay(s *Subscriber) { for i := 0; i < len((*e)); i++ { if string((*e)[i].ID) >= s.eventid { s.connection <- (*e)[i] } } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L3309-L3313
func (v *EventExecutionContextsCleared) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoRuntime30(&r, v) return r.Error() }
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/mocktracer/mockspan.go#L121-L125
func (s *MockSpan) Tag(k string) interface{} { s.RLock() defer s.RUnlock() return s.tags[k] }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/merge.go#L272-L295
func SquashRules(src, dst *Rule, filename string) error { if dst.ShouldKeep() { return nil } for key, srcAttr := range src.attrs { srcValue := srcAttr.RHS if dstAttr, ok := dst.attrs[key]; !ok { dst.SetAttr(key, srcValue) } else if !ShouldKeep(dstAttr) { dstValue := dstAttr.RHS if squashedValue, err := squashExprs(srcValue, dstValue); err != nil { start, end := dstValue.Span() return fmt.Errorf("%s:%d.%d-%d.%d: could not squash expression", filename, start.Line, start.LineRune, end.Line, end.LineRune) } else { dst.SetAttr(key, squashedValue) } } } dst.expr.Comment().Before = append(dst.expr.Comment().Before, src.expr.Comment().Before...) dst.expr.Comment().Suffix = append(dst.expr.Comment().Suffix, src.expr.Comment().Suffix...) dst.expr.Comment().After = append(dst.expr.Comment().After, src.expr.Comment().After...) return nil }
https://github.com/libp2p/go-libp2p-net/blob/a60cde50df6872512892ca85019341d281f72a42/notifiee.go#L31-L35
func (nb *NotifyBundle) ListenClose(n Network, a ma.Multiaddr) { if nb.ListenCloseF != nil { nb.ListenCloseF(n, a) } }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/ca/cac/codegen_client.go#L2012-L2014
func (api *API) InstanceUsagePeriodLocator(href string) *InstanceUsagePeriodLocator { return &InstanceUsagePeriodLocator{Href(href), api} }
https://github.com/pact-foundation/pact-go/blob/467dea56d27e154363e1975f6e9f4dbf66148e79/install/installer.go#L57-L78
func (i *Installer) CheckVersion(binary, version string) error { log.Println("[DEBUG] checking version for binary", binary, "version", version) v, err := goversion.NewVersion(version) if err != nil { log.Println("[DEBUG] err", err) return err } versionRange, ok := versionMap[binary] if !ok { return fmt.Errorf("unable to find version range for binary %s", binary) } log.Println("[DEBUG] checking if version", v, "within semver range", versionRange) constraints, err := goversion.NewConstraint(versionRange) if constraints.Check(v) { log.Println("[DEBUG]", v, "satisfies constraints", v, constraints) return nil } return fmt.Errorf("version %s of %s does not match constraint %s", version, binary, versionRange) }
https://github.com/reiver/go-telnet/blob/9ff0b2ab096ebe42bf8e2ffd1366e7ed2223b04c/data_writer.go#L71-L77
func newDataWriter(w io.Writer) *internalDataWriter { writer := internalDataWriter{ wrapped:w, } return &writer }
https://github.com/armon/go-radix/blob/1a2de0c21c94309923825da3df33a4381872c795/radix.go#L295-L297
func (t *Tree) DeletePrefix(s string) int { return t.deletePrefix(nil, t.root, s) }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/connection.go#L390-L403
func (c *Connection) ping(ctx context.Context) error { req := &pingReq{id: c.NextMessageID()} mex, err := c.outbound.newExchange(ctx, c.opts.FramePool, req.messageType(), req.ID(), 1) if err != nil { return c.connectionError("create ping exchange", err) } defer c.outbound.removeExchange(req.ID()) if err := c.sendMessage(req); err != nil { return c.connectionError("send ping", err) } return c.recvMessage(ctx, &pingRes{}, mex) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/pkg/ghclient/wrappers.go#L106-L142
func (c *Client) ForEachPR(owner, repo string, opts *github.PullRequestListOptions, continueOnError bool, mungePR PRMungeFunc) error { var lastPage int // Munge each page as we get it (or in other words, wait until we are ready to munge the next // page of issues before getting it). We use depaginate to make the calls, but don't care about // the slice it returns since we consume the pages as we go. _, err := c.depaginate( "processing PRs", &opts.ListOptions, func() ([]interface{}, *github.Response, error) { list, resp, err := c.prService.List(context.Background(), owner, repo, opts) if err == nil { for _, pr := range list { if pr == nil { glog.Errorln("Received a nil PR from go-github while listing PRs. Skipping...") } if mungeErr := mungePR(pr); mungeErr != nil { if pr.Number == nil { mungeErr = fmt.Errorf("error munging pull request with nil Number field: %v", mungeErr) } else { mungeErr = fmt.Errorf("error munging pull request #%d: %v", *pr.Number, mungeErr) } if !continueOnError { return nil, resp, &retryAbort{mungeErr} } glog.Errorf("%v\n", mungeErr) } } if resp.LastPage > 0 { lastPage = resp.LastPage } glog.Infof("ForEachPR processed page %d/%d\n", opts.ListOptions.Page, lastPage) } return nil, resp, err }, ) return err }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/signature/policy_config.go#L603-L615
func newPRMExactReference(dockerReference string) (*prmExactReference, error) { ref, err := reference.ParseNormalizedNamed(dockerReference) if err != nil { return nil, InvalidPolicyFormatError(fmt.Sprintf("Invalid format of dockerReference %s: %s", dockerReference, err.Error())) } if reference.IsNameOnly(ref) { return nil, InvalidPolicyFormatError(fmt.Sprintf("dockerReference %s contains neither a tag nor digest", dockerReference)) } return &prmExactReference{ prmCommon: prmCommon{Type: prmTypeExactReference}, DockerReference: dockerReference, }, nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_post.go#L517-L549
func containerPostCreateContainerMountPoint(d *Daemon, project, containerName string) error { c, err := containerLoadByProjectAndName(d.State(), project, containerName) if err != nil { return errors.Wrap(err, "Failed to load moved container on target node") } poolName, err := c.StoragePool() if err != nil { return errors.Wrap(err, "Failed get pool name of moved container on target node") } snapshotNames, err := d.cluster.ContainerGetSnapshots(project, containerName) if err != nil { return errors.Wrap(err, "Failed to create container snapshot names") } containerMntPoint := getContainerMountPoint(c.Project(), poolName, containerName) err = createContainerMountpoint(containerMntPoint, c.Path(), c.IsPrivileged()) if err != nil { return errors.Wrap(err, "Failed to create container mount point on target node") } for _, snapshotName := range snapshotNames { mntPoint := getSnapshotMountPoint(project, poolName, snapshotName) snapshotsSymlinkTarget := shared.VarPath("storage-pools", poolName, "containers-snapshots", containerName) snapshotMntPointSymlink := shared.VarPath("snapshots", containerName) err := createSnapshotMountpoint(mntPoint, snapshotsSymlinkTarget, snapshotMntPointSymlink) if err != nil { return errors.Wrap(err, "Failed to create snapshot mount point on target node") } } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/cachestorage/cachestorage.go#L184-L193
func (p *RequestEntriesParams) Do(ctx context.Context) (cacheDataEntries []*DataEntry, returnCount float64, err error) { // execute var res RequestEntriesReturns err = cdp.Execute(ctx, CommandRequestEntries, p, &res) if err != nil { return nil, 0, err } return res.CacheDataEntries, res.ReturnCount, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/maintenance/aws-janitor/resources/route53.go#L35-L44
func zoneIsManaged(z *route53.HostedZone) bool { // TODO: Move to a tag on the zone? name := aws.StringValue(z.Name) if "test-cncf-aws.k8s.io." == name { return true } klog.Infof("unknown zone %q; ignoring", name) return false }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/client.go#L174-L179
func WithMaxConcurrentStreams(streams int) Option { return func(settings *clientSettings) error { settings.maxConcurrentStreams = streams return nil } }
https://github.com/rlmcpherson/s3gof3r/blob/864ae0bf7cf2e20c0002b7ea17f4d84fec1abc14/s3gof3r.go#L99-L105
func (s *S3) Bucket(name string) *Bucket { return &Bucket{ S3: s, Name: name, Config: DefaultConfig, } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/ghproxy/ghproxy.go#L158-L172
func diskMonitor(interval time.Duration, diskRoot string) { logger := logrus.WithField("sync-loop", "disk-monitor") ticker := time.NewTicker(interval) for ; true; <-ticker.C { logger.Info("tick") _, bytesFree, bytesUsed, err := diskutil.GetDiskUsage(diskRoot) if err != nil { logger.WithError(err).Error("Failed to get disk metrics") } else { diskFree.Set(float64(bytesFree) / 1e9) diskUsed.Set(float64(bytesUsed) / 1e9) diskTotal.Set(float64(bytesFree+bytesUsed) / 1e9) } } }
https://github.com/urandom/handler/blob/61508044a5569d1609521d81e81f6737567fd104/auth/jwt.go#L63-L67
func Logger(l handler.Logger) TokenOpt { return TokenOpt{func(o *options) { o.logger = l }} }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxc/config/remote.go#L111-L177
func (c *Config) GetImageServer(name string) (lxd.ImageServer, error) { // Get the remote remote, ok := c.Remotes[name] if !ok { return nil, fmt.Errorf("The remote \"%s\" doesn't exist", name) } // Get connection arguments args, err := c.getConnectionArgs(name) if err != nil { return nil, err } // Unix socket if strings.HasPrefix(remote.Addr, "unix:") { d, err := lxd.ConnectLXDUnix(strings.TrimPrefix(strings.TrimPrefix(remote.Addr, "unix:"), "//"), args) if err != nil { return nil, err } if remote.Project != "" && remote.Project != "default" { d = d.UseProject(remote.Project) } if c.ProjectOverride != "" { d = d.UseProject(c.ProjectOverride) } return d, nil } // HTTPs (simplestreams) if remote.Protocol == "simplestreams" { d, err := lxd.ConnectSimpleStreams(remote.Addr, args) if err != nil { return nil, err } return d, nil } // HTTPs (public LXD) if remote.Public { d, err := lxd.ConnectPublicLXD(remote.Addr, args) if err != nil { return nil, err } return d, nil } // HTTPs (private LXD) d, err := lxd.ConnectLXD(remote.Addr, args) if err != nil { return nil, err } if remote.Project != "" && remote.Project != "default" { d = d.UseProject(remote.Project) } if c.ProjectOverride != "" { d = d.UseProject(c.ProjectOverride) } return d, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/profiler/easyjson.go#L857-L861
func (v StartTypeProfileParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoProfiler10(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/rlmcpherson/s3gof3r/blob/864ae0bf7cf2e20c0002b7ea17f4d84fec1abc14/s3gof3r.go#L233-L238
func SetLogger(out io.Writer, prefix string, flag int, debug bool) { logger = internalLogger{ log.New(out, prefix, flag), debug, } }
https://github.com/onsi/gomega/blob/f0e010e04c08c48a875f83d17df37b04eb3a985b/matchers.go#L337-L343
func BeTemporally(comparator string, compareTo time.Time, threshold ...time.Duration) types.GomegaMatcher { return &matchers.BeTemporallyMatcher{ Comparator: comparator, CompareTo: compareTo, Threshold: threshold, } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/storage_volumes.go#L293-L308
func storageVolumeIDsGet(tx *sql.Tx, project, volumeName string, volumeType int, poolID int64) ([]int64, error) { ids, err := query.SelectIntegers(tx, ` SELECT storage_volumes.id FROM storage_volumes JOIN projects ON projects.id = storage_volumes.project_id WHERE projects.name=? AND storage_volumes.name=? AND storage_volumes.type=? AND storage_pool_id=? `, project, volumeName, volumeType, poolID) if err != nil { return nil, err } ids64 := make([]int64, len(ids)) for i, id := range ids { ids64[i] = int64(id) } return ids64, nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_certificates.go#L47-L57
func (r *ProtocolLXD) GetCertificate(fingerprint string) (*api.Certificate, string, error) { certificate := api.Certificate{} // Fetch the raw value etag, err := r.queryStruct("GET", fmt.Sprintf("/certificates/%s", url.QueryEscape(fingerprint)), nil, "", &certificate) if err != nil { return nil, "", err } return &certificate, etag, nil }
https://github.com/tomasen/realip/blob/f0c99a92ddcedd3964a269d23c8e89d9a9229be6/realip.go#L37-L50
func isPrivateAddress(address string) (bool, error) { ipAddress := net.ParseIP(address) if ipAddress == nil { return false, errors.New("address is not valid") } for i := range cidrs { if cidrs[i].Contains(ipAddress) { return true, nil } } return false, nil }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L2647-L2654
func (u PaymentResult) ArmForSwitch(sw int32) (string, bool) { switch PaymentResultCode(sw) { case PaymentResultCodePaymentSuccess: return "", true default: return "", true } }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pkg/require/require.go#L25-L38
func OneOfMatches(tb testing.TB, expectedMatch string, actuals []string, msgAndArgs ...interface{}) { tb.Helper() r, err := regexp.Compile(expectedMatch) if err != nil { fatal(tb, msgAndArgs, "Match string provided (%v) is invalid", expectedMatch) } for _, actual := range actuals { if r.MatchString(actual) { return } } fatal(tb, msgAndArgs, "None of actual strings (%v) match pattern (%v)", actuals, expectedMatch) }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/storage/storage_image.go#L294-L316
func (s *storageImageSource) GetSignatures(ctx context.Context, instanceDigest *digest.Digest) (signatures [][]byte, err error) { if instanceDigest != nil { return nil, ErrNoManifestLists } var offset int sigslice := [][]byte{} signature := []byte{} if len(s.SignatureSizes) > 0 { signatureBlob, err := s.imageRef.transport.store.ImageBigData(s.image.ID, "signatures") if err != nil { return nil, errors.Wrapf(err, "error looking up signatures data for image %q", s.image.ID) } signature = signatureBlob } for _, length := range s.SignatureSizes { sigslice = append(sigslice, signature[offset:offset+length]) offset += length } if offset != len(signature) { return nil, errors.Errorf("signatures data contained %d extra bytes", len(signatures)-offset) } return sigslice, nil }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/flash.go#L29-L36
func (f Flash) Add(key, value string) { if len(f.data[key]) == 0 { f.data[key] = []string{value} return } f.data[key] = append(f.data[key], value) }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/repo/remote.go#L268-L281
func (r *RemoteCache) Remote(root string) (remote, vcs string, err error) { v, err := r.remote.ensure(root, func() (interface{}, error) { repo, err := r.RepoRootForImportPath(root, false) if err != nil { return nil, err } return remoteValue{remote: repo.Repo, vcs: repo.VCS.Cmd}, nil }) if err != nil { return "", "", err } value := v.(remoteValue) return value.remote, value.vcs, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/emulation.go#L76-L78
func (p *ClearGeolocationOverrideParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandClearGeolocationOverride, nil, nil) }
https://github.com/HiLittleCat/core/blob/ae2101184ecd36354d3fcff0ea69d67d3fdbe156/routergroup.go#L50-L53
func (group *RouterGroup) Use(middleware ...RouterHandler) IRoutes { group.Handlers = append(group.Handlers, middleware...) return group.returnObj() }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/router/router.go#L92-L109
func Default() (string, error) { plans, err := List() if err != nil { return "", err } if len(plans) == 0 { return "", ErrDefaultRouterNotFound } if len(plans) == 1 { return plans[0].Name, nil } for _, p := range plans { if p.Default { return p.Name, nil } } return "", ErrDefaultRouterNotFound }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/mail/mail.go#L73-L75
func SendToAdmins(c context.Context, msg *Message) error { return send(c, "SendToAdmins", msg) }
https://github.com/golang/debug/blob/19561fee47cf8cd0400d1b094c5898002f97cf90/internal/gocore/dominator.go#L343-L384
func (d *dominators) calcSize(p *Process) { d.size = make([]int64, len(d.idom)) type workItem struct { v vName mode dfsMode } work := []workItem{{pseudoRoot, down}} for len(work) > 0 { item := &work[len(work)-1] kids := d.redge[d.ridx[item.v]:d.ridx[item.v+1]] if item.mode == down && len(kids) != 0 { item.mode = up for _, w := range kids { if w == 0 { // bogus self-edge. Ignore. continue } work = append(work, workItem{w, down}) } continue } work = work[:len(work)-1] root, obj := d.findVertexByName(item.v) var size int64 switch { case item.v == pseudoRoot: break case root != nil: size += root.Type.Size default: size += p.Size(obj) } for _, w := range kids { size += d.size[w] } d.size[item.v] = size } }
https://github.com/libp2p/go-libp2p-pubsub/blob/9db3dbdde90f44d1c420192c5cefd60682fbdbb9/pubsub.go#L544-L546
func (p *PubSub) seenMessage(id string) bool { return p.seenMessages.Has(id) }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/merger/fix.go#L30-L98
func FixLoads(f *rule.File, knownLoads []rule.LoadInfo) { knownFiles := make(map[string]bool) knownKinds := make(map[string]string) for _, l := range knownLoads { knownFiles[l.Name] = true for _, k := range l.Symbols { knownKinds[k] = l.Name } } // Sync the file. We need File.Loads and File.Rules to contain inserted // statements and not deleted statements. f.Sync() // Scan load statements in the file. Keep track of loads of known files, // since these may be changed. Keep track of symbols loaded from unknown // files; we will not add loads for these. var loads []*rule.Load otherLoadedKinds := make(map[string]bool) for _, l := range f.Loads { if knownFiles[l.Name()] { loads = append(loads, l) continue } for _, sym := range l.Symbols() { otherLoadedKinds[sym] = true } } // Make a map of all the symbols from known files used in this file. usedKinds := make(map[string]map[string]bool) for _, r := range f.Rules { kind := r.Kind() if file, ok := knownKinds[kind]; ok && !otherLoadedKinds[kind] { if usedKinds[file] == nil { usedKinds[file] = make(map[string]bool) } usedKinds[file][kind] = true } } // Fix the load statements. The order is important, so we iterate over // knownLoads instead of knownFiles. for _, known := range knownLoads { file := known.Name first := true for _, l := range loads { if l.Name() != file { continue } if first { fixLoad(l, file, usedKinds[file], knownKinds) first = false } else { fixLoad(l, file, nil, knownKinds) } if l.IsEmpty() { l.Delete() } } if first { load := fixLoad(nil, file, usedKinds[file], knownKinds) if load != nil { index := newLoadIndex(f, known.After) load.Insert(f, index) } } } }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/db/storage/open.go#L22-L44
func Open(addr, dbname string) (storage *Storage, err error) { sessionLock.RLock() if sessions[addr] == nil { sessionLock.RUnlock() sessionLock.Lock() if sessions[addr] == nil { sessions[addr], err = open(addr) } sessionLock.Unlock() if err != nil { return } } else { sessionLock.RUnlock() } cloned := sessions[addr].Clone() runtime.SetFinalizer(cloned, sessionFinalizer) storage = &Storage{ session: cloned, dbname: dbname, } return }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/datastore/prop.go#L105-L128
func validPropertyName(name string) bool { if name == "" { return false } for _, s := range strings.Split(name, ".") { if s == "" { return false } first := true for _, c := range s { if first { first = false if c != '_' && !unicode.IsLetter(c) { return false } } else { if c != '_' && !unicode.IsLetter(c) && !unicode.IsDigit(c) { return false } } } } return true }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/hashtree/db.go#L1353-L1360
func HashFileNode(n *FileNodeProto) []byte { hash := sha256.New() // Compute n.Hash by concatenating all BlockRef hashes in n.FileNode. for _, object := range n.Objects { hash.Write([]byte(object.Hash)) } return hash.Sum(nil) }
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L936-L941
func (g *Glg) PrintFunc(f func() string) error { if g.isModeEnable(PRINT) { return g.out(PRINT, "%s", f()) } return nil }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/font.go#L138-L156
func (cache *FolderFontCache) Load(fontData FontData) (font *truetype.Font, err error) { if font = cache.fonts[cache.namer(fontData)]; font != nil { return font, nil } var data []byte var file = cache.namer(fontData) if data, err = ioutil.ReadFile(filepath.Join(cache.folder, file)); err != nil { return } if font, err = truetype.Parse(data); err != nil { return } cache.fonts[file] = font return }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/runtime/runtime.go#L69-L76
func init() { http.HandleFunc("/_ah/background", handleBackground) sc := make(chan send) rc := make(chan recv) sendc, recvc = sc, rc go matchmaker(sc, rc) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cmd/ask.go#L62-L82
func AskString(question string, defaultAnswer string, validate func(string) error) string { for { answer := askQuestion(question, defaultAnswer) if validate != nil { error := validate(answer) if error != nil { fmt.Fprintf(os.Stderr, "Invalid input: %s\n\n", error) continue } return answer } if len(answer) != 0 { return answer } invalidInput() } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/easyjson.go#L3482-L3486
func (v *GetNodeForLocationParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoDom39(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/overlay/easyjson.go#L1460-L1464
func (v HighlightConfig) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoOverlay13(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/util.go#L100-L105
func decodeMsgPack(buf []byte, out interface{}) error { r := bytes.NewBuffer(buf) hd := codec.MsgpackHandle{} dec := codec.NewDecoder(r, &hd) return dec.Decode(out) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/stringutil/rand.go#L23-L34
func UniqueStrings(slen uint, n int) (ss []string) { exist := make(map[string]struct{}) ss = make([]string, 0, n) for len(ss) < n { s := randString(slen) if _, ok := exist[s]; !ok { ss = append(ss, s) exist[s] = struct{}{} } } return ss }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/tracer.go#L99-L106
func (t *Tracer) Last() opentracing.Span { // return root if empty if len(t.spans) == 0 { return t.root } return t.spans[len(t.spans)-1] }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L281-L283
func (p *EnableParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandEnable, p, nil) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/api/response.go#L56-L64
func (r *Response) MetadataAsOperation() (*Operation, error) { op := Operation{} err := r.MetadataAsStruct(&op) if err != nil { return nil, err } return &op, nil }