_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/network.go#L116-L119
func (p ContinueInterceptedRequestParams) WithPostData(postData string) *ContinueInterceptedRequestParams { p.PostData = postData return &p }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/auth/options.go#L97-L108
func (opts *jwtOptions) Key() (interface{}, error) { switch opts.SignMethod.(type) { case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS: return opts.rsaKey() case *jwt.SigningMethodECDSA: return opts.ecKey() case *jwt.SigningMethodHMAC: return opts.hmacKey() default: return nil, fmt.Errorf("unsupported signing method: %T", opts.SignMethod) } }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L6623-L6631
func (u StellarMessage) MustTxSet() TransactionSet { val, ok := u.GetTxSet() if !ok { panic("arm TxSet is not set") } return val }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v3compactor/revision.go#L139-L143
func (rc *Revision) Resume() { rc.mu.Lock() rc.paused = false rc.mu.Unlock() }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry.go#L230-L234
func RetryAuthClient(c *Client) pb.AuthClient { return &retryAuthClient{ ac: pb.NewAuthClient(c.conn), } }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/selection_properties.go#L100-L102
func (s *Selection) Enabled() (bool, error) { return s.hasState(element.Element.IsEnabled, "enabled") }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/app/app.go#L384-L438
func CreateApp(app *App, user *auth.User) error { if _, err := GetByName(app.GetName()); err != appTypes.ErrAppNotFound { if err != nil { return errors.WithMessage(err, "unable to check if app already exists") } return &appTypes.AppCreationError{Err: ErrAppAlreadyExists, App: app.GetName()} } var plan *appTypes.Plan var err error if app.Plan.Name == "" { plan, err = servicemanager.Plan.DefaultPlan() } else { plan, err = servicemanager.Plan.FindByName(app.Plan.Name) } if err != nil { return err } app.Plan = *plan err = app.SetPool() if err != nil { return err } err = app.configureCreateRouters() if err != nil { return err } app.Teams = []string{app.TeamOwner} app.Owner = user.Email app.Tags = processTags(app.Tags) if app.Platform != "" { app.Platform, app.PlatformVersion, err = getPlatformNameAndVersion(app.Platform) if err != nil { return err } } err = app.validateNew() if err != nil { return err } actions := []*action.Action{ &reserveUserApp, &insertApp, &createAppToken, &exportEnvironmentsAction, &createRepository, &provisionApp, &addRouterBackend, } pipeline := action.NewPipeline(actions...) err = pipeline.Execute(app, user) if err != nil { return &appTypes.AppCreationError{App: app.Name, Err: err} } return nil }
https://github.com/mgutz/str/blob/968bf66e3da857419e4f6e71b2d5c9ae95682dc4/funcsPZ.go#L390-L396
func ToBoolOr(s string, defaultValue bool) bool { b, err := strconv.ParseBool(s) if err != nil { return defaultValue } return b }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L6681-L6685
func (v CreateIsolatedWorldReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage72(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/pad.go#L127-L176
func PadFrameRange(frange string, pad int) string { // We don't need to do anything if they gave us // an invalid pad number if pad < 2 { return frange } size := strings.Count(frange, ",") + 1 parts := make([]string, size, size) for i, part := range strings.Split(frange, ",") { didMatch := false for _, rx := range rangePatterns { matched := rx.FindStringSubmatch(part) if len(matched) == 0 { continue } matched = matched[1:] size = len(matched) switch size { case 1: parts[i] = zfillString(matched[0], pad) case 2: parts[i] = fmt.Sprintf("%s-%s", zfillString(matched[0], pad), zfillString(matched[1], pad)) case 4: parts[i] = fmt.Sprintf("%s-%s%s%s", zfillString(matched[0], pad), zfillString(matched[1], pad), matched[2], matched[3]) default: // No match. Try the next pattern continue } // If we got here, we matched a case and can stop // checking the rest of the patterns didMatch = true break } // If we didn't match one of our expected patterns // then just take the original part and add it unmodified if !didMatch { parts = append(parts, part) } } return strings.Join(parts, ",") }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/iterator.go#L449-L453
func (it *Iterator) Item() *Item { tx := it.txn tx.addReadKey(it.item.Key()) return it.item }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/label/label.go#L156-L164
func (l Label) Rel(repo, pkg string) Label { if l.Relative || l.Repo != repo { return l } if l.Pkg == pkg { return Label{Name: l.Name, Relative: true} } return Label{Pkg: l.Pkg, Name: l.Name} }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv2/command/rm_command.go#L44-L63
func rmCommandFunc(c *cli.Context, ki client.KeysAPI) { if len(c.Args()) == 0 { handleError(c, ExitBadArgs, errors.New("key required")) } key := c.Args()[0] recursive := c.Bool("recursive") dir := c.Bool("dir") prevValue := c.String("with-value") prevIndex := c.Int("with-index") ctx, cancel := contextWithTotalTimeout(c) resp, err := ki.Delete(ctx, key, &client.DeleteOptions{PrevIndex: uint64(prevIndex), PrevValue: prevValue, Dir: dir, Recursive: recursive}) cancel() if err != nil { handleError(c, ExitServerError, err) } if !resp.Node.Dir || c.GlobalString("output") != "simple" { printResponseKey(resp, c.GlobalString("output")) } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/v2http/client.go#L751-L756
func getBool(form url.Values, key string) (b bool, err error) { if vals, ok := form[key]; ok { b, err = strconv.ParseBool(vals[0]) } return }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L7986-L7993
func (r *PublicationLineage) Locator(api *API) *PublicationLineageLocator { for _, l := range r.Links { if l["rel"] == "self" { return api.PublicationLineageLocator(l["href"]) } } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/browser/easyjson.go#L1546-L1550
func (v *GetBrowserCommandLineParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoBrowser16(&r, v) return r.Error() }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/storage/storage_reference.go#L200-L202
func (s storageReference) NewImage(ctx context.Context, sys *types.SystemContext) (types.ImageCloser, error) { return newImage(ctx, sys, s) }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/node.go#L447-L472
func nodeHealingRead(w http.ResponseWriter, r *http.Request, t auth.Token) error { pools, err := permission.ListContextValues(t, permission.PermHealingRead, true) if err != nil { return err } configMap, err := healer.GetConfig() if err != nil { return err } if len(pools) > 0 { allowedPoolSet := map[string]struct{}{} for _, p := range pools { allowedPoolSet[p] = struct{}{} } for k := range configMap { if k == "" { continue } if _, ok := allowedPoolSet[k]; !ok { delete(configMap, k) } } } w.Header().Set("Content-Type", "application/json") return json.NewEncoder(w).Encode(configMap) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/indexeddb/indexeddb.go#L164-L167
func (p RequestDataParams) WithKeyRange(keyRange *KeyRange) *RequestDataParams { p.KeyRange = keyRange return &p }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L214-L227
func (m ClearFlag) MutateSetOptions(o *xdr.SetOptionsOp) (err error) { if !isFlagValid(xdr.AccountFlags(m)) { return errors.New("Unknown flag in SetFlag mutator") } var val xdr.Uint32 if o.ClearFlags == nil { val = xdr.Uint32(m) } else { val = xdr.Uint32(m) | *o.ClearFlags } o.ClearFlags = &val return }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/lookaside.go#L48-L74
func configuredSignatureStorageBase(sys *types.SystemContext, ref dockerReference, write bool) (signatureStorageBase, error) { // FIXME? Loading and parsing the config could be cached across calls. dirPath := registriesDirPath(sys) logrus.Debugf(`Using registries.d directory %s for sigstore configuration`, dirPath) config, err := loadAndMergeConfig(dirPath) if err != nil { return nil, err } topLevel := config.signatureTopLevel(ref, write) if topLevel == "" { return nil, nil } url, err := url.Parse(topLevel) if err != nil { return nil, errors.Wrapf(err, "Invalid signature storage URL %s", topLevel) } // NOTE: Keep this in sync with docs/signature-protocols.md! // FIXME? Restrict to explicitly supported schemes? repo := reference.Path(ref.ref) // Note that this is without a tag or digest. if path.Clean(repo) != repo { // Coverage: This should not be reachable because /./ and /../ components are not valid in docker references return nil, errors.Errorf("Unexpected path elements in Docker reference %s for signature storage", ref.ref.String()) } url.Path = url.Path + "/" + repo return url, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/tide/tide.go#L268-L274
func contextsToStrings(contexts []Context) []string { var names []string for _, c := range contexts { names = append(names, string(c.Context)) } return names }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/dom.go#L307-L316
func (p *GetAttributesParams) Do(ctx context.Context) (attributes []string, err error) { // execute var res GetAttributesReturns err = cdp.Execute(ctx, CommandGetAttributes, p, &res) if err != nil { return nil, err } return res.Attributes, nil }
https://github.com/kpango/glg/blob/68d2670cb2dbff047331daad841149a82ac37796/glg.go#L990-L992
func Errorf(format string, val ...interface{}) error { return glg.out(ERR, format, val...) }
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/usermanagment.go#L320-L325
func (c *Client) GetResourceByType(resourcetype string, resourceid string) (*Resource, error) { url := umResourcesTypePath(resourcetype, resourceid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Resource{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/storage_volumes.go#L70-L150
func storagePoolVolumesGet(d *Daemon, r *http.Request) Response { project := projectParam(r) poolName := mux.Vars(r)["name"] recursion := util.IsRecursionRequest(r) // Retrieve ID of the storage pool (and check if the storage pool // exists). poolID, err := d.cluster.StoragePoolGetID(poolName) if err != nil { return SmartError(err) } // Get all volumes currently attached to the storage pool by ID of the // pool and project. // // We exclude volumes of type image, since those are special: they are // stored using the storage_volumes table, but are effectively a cache // which is not tied to projects, so we always link the to the default // project. This means that we want to filter image volumes and return // only the ones that have fingerprints matching images actually in use // by the project. volumes, err := d.cluster.StoragePoolVolumesGet(project, poolID, supportedVolumeTypesExceptImages) if err != nil && err != db.ErrNoSuchObject { return SmartError(err) } imageVolumes, err := d.cluster.StoragePoolVolumesGet("default", poolID, []int{storagePoolVolumeTypeImage}) if err != nil && err != db.ErrNoSuchObject { return SmartError(err) } projectImages, err := d.cluster.ImagesGet(project, false) if err != nil { return SmartError(err) } for _, volume := range imageVolumes { if shared.StringInSlice(volume.Name, projectImages) { volumes = append(volumes, volume) } } resultString := []string{} for _, volume := range volumes { apiEndpoint, err := storagePoolVolumeTypeNameToAPIEndpoint(volume.Type) if err != nil { return InternalError(err) } if apiEndpoint == storagePoolVolumeAPIEndpointContainers { apiEndpoint = "container" } else if apiEndpoint == storagePoolVolumeAPIEndpointImages { apiEndpoint = "image" } if !recursion { volName, snapName, ok := containerGetParentAndSnapshotName(volume.Name) if ok { resultString = append(resultString, fmt.Sprintf("/%s/storage-pools/%s/volumes/%s/%s/snapshots/%s", version.APIVersion, poolName, apiEndpoint, volName, snapName)) } else { resultString = append(resultString, fmt.Sprintf("/%s/storage-pools/%s/volumes/%s/%s", version.APIVersion, poolName, apiEndpoint, volume.Name)) } } else { volumeUsedBy, err := storagePoolVolumeUsedByGet(d.State(), project, volume.Name, volume.Type) if err != nil { return InternalError(err) } volume.UsedBy = volumeUsedBy } } if !recursion { return SyncResponse(true, resultString) } return SyncResponse(true, volumes) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/log/log.go#L246-L248
func (f FormatterFunc) Format(entry *logrus.Entry) ([]byte, error) { return f(entry) }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L180-L188
func (c APIClient) InspectJob(jobID string, blockState bool) (*pps.JobInfo, error) { jobInfo, err := c.PpsAPIClient.InspectJob( c.Ctx(), &pps.InspectJobRequest{ Job: NewJob(jobID), BlockState: blockState, }) return jobInfo, grpcutil.ScrubGRPC(err) }
https://github.com/qor/render/blob/63566e46f01b134ae9882a59a06518e82a903231/render.go#L35-L57
func New(config *Config, viewPaths ...string) *Render { if config == nil { config = &Config{} } if config.DefaultLayout == "" { config.DefaultLayout = DefaultLayout } if config.AssetFileSystem == nil { config.AssetFileSystem = assetfs.AssetFS().NameSpace("views") } config.ViewPaths = append(append(config.ViewPaths, viewPaths...), DefaultViewPath) render := &Render{funcMaps: map[string]interface{}{}, Config: config} for _, viewPath := range config.ViewPaths { render.RegisterViewPath(viewPath) } return render }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/easyjson.go#L210-L214
func (v *SetVirtualTimePolicyParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoEmulation1(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/backgroundservice/easyjson.go#L320-L324
func (v *EventRecordingStateChanged) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoBackgroundservice3(&r, v) return r.Error() }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L283-L345
func (s *Skiplist) Put(key []byte, v y.ValueStruct) { // Since we allow overwrite, we may not need to create a new node. We might not even need to // increase the height. Let's defer these actions. listHeight := s.getHeight() var prev [maxHeight + 1]*node var next [maxHeight + 1]*node prev[listHeight] = s.head next[listHeight] = nil for i := int(listHeight) - 1; i >= 0; i-- { // Use higher level to speed up for current level. prev[i], next[i] = s.findSpliceForLevel(key, prev[i+1], i) if prev[i] == next[i] { prev[i].setValue(s.arena, v) return } } // We do need to create a new node. height := randomHeight() x := newNode(s.arena, key, v, height) // Try to increase s.height via CAS. listHeight = s.getHeight() for height > int(listHeight) { if atomic.CompareAndSwapInt32(&s.height, listHeight, int32(height)) { // Successfully increased skiplist.height. break } listHeight = s.getHeight() } // We always insert from the base level and up. After you add a node in base level, we cannot // create a node in the level above because it would have discovered the node in the base level. for i := 0; i < height; i++ { for { if prev[i] == nil { y.AssertTrue(i > 1) // This cannot happen in base level. // We haven't computed prev, next for this level because height exceeds old listHeight. // For these levels, we expect the lists to be sparse, so we can just search from head. prev[i], next[i] = s.findSpliceForLevel(key, s.head, i) // Someone adds the exact same key before we are able to do so. This can only happen on // the base level. But we know we are not on the base level. y.AssertTrue(prev[i] != next[i]) } nextOffset := s.arena.getNodeOffset(next[i]) x.tower[i] = nextOffset if prev[i].casNextOffset(i, nextOffset, s.arena.getNodeOffset(x)) { // Managed to insert x between prev[i] and next[i]. Go to the next level. break } // CAS failed. We need to recompute prev and next. // It is unlikely to be helpful to try to use a different level as we redo the search, // because it is unlikely that lots of nodes are inserted between prev[i] and next[i]. prev[i], next[i] = s.findSpliceForLevel(key, prev[i], i) if prev[i] == next[i] { y.AssertTruef(i == 0, "Equality can happen only on base level: %d", i) prev[i].setValue(s.arena, v) return } } } }
https://github.com/coryb/figtree/blob/e5fa026ccd54e0a6a99b6d81f73bfcc8e6fe6a6b/rawoption.go#L137-L146
func (o *MapRawTypeOption) Set(value string) error { parts := stringMapRegex.Split(value, 2) if len(parts) != 2 { return fmt.Errorf("expected KEY=VALUE got '%s'", value) } val := RawTypeOption{} val.Set(parts[1]) (*o)[parts[0]] = val return nil }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/genny/newapp/api/api.go#L13-L37
func New(opts *Options) (*genny.Group, error) { if err := opts.Validate(); err != nil { return nil, err } gg, err := core.New(opts.Options) if err != nil { return gg, err } g := genny.New() data := map[string]interface{}{ "opts": opts, } helpers := template.FuncMap{} t := gogen.TemplateTransformer(data, helpers) g.Transformer(t) g.Box(packr.New("buffalo:genny:newapp:api", "../api/templates")) gg.Add(g) return gg, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/target/target.go#L464-L467
func (p SendMessageToTargetParams) WithSessionID(sessionID SessionID) *SendMessageToTargetParams { p.SessionID = sessionID return &p }
https://github.com/ikawaha/kagome.ipadic/blob/fe03f87a0c7c32945d956fcfc934c3e11d5eb182/cmd/kagome/server/cmd.go#L89-L113
func command(opt *option) error { var dic tokenizer.Dic if opt.sysdic == "simple" { dic = tokenizer.SysDicIPASimple() } else { dic = tokenizer.SysDic() } t := tokenizer.NewWithDic(dic) var udic tokenizer.UserDic if opt.udic != "" { var err error if udic, err = tokenizer.NewUserDic(opt.udic); err != nil { return err } } t.SetUserDic(udic) mux := http.NewServeMux() mux.Handle("/", &TokenizeDemoHandler{tokenizer: t}) mux.Handle("/a", &TokenizeHandler{tokenizer: t}) log.Fatal(http.ListenAndServe(opt.http, mux)) return nil }
https://github.com/blacklabeldata/namedtuple/blob/c341f1db44f30b8164294aa8605ede42be604aba/schema/parser.go#L100-L102
func LoadPackage(parser Parser, name, text string) (Package, error) { return parser.Parse(name, text) }
https://github.com/t3rm1n4l/nitro/blob/937fe99f63a01a8bea7661c49e2f3f8af6541d7c/mm/malloc.go#L36-L41
func Malloc(l int) unsafe.Pointer { if Debug { atomic.AddUint64(&stats.allocs, 1) } return C.mm_malloc(C.size_t(l)) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/stream.go#L332-L337
func (db *DB) NewStream() *Stream { if db.opt.managedTxns { panic("This API can not be called in managed mode.") } return db.newStream() }
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/vm/vm.go#L52-L91
func (vm *VM) Run(bc *ByteCode, vars Vars, output io.Writer) { if !vm.IsSupportedByteCodeVersion(bc) { panic(fmt.Sprintf( "error: ByteCode version %f no supported", bc.Version, )) } st := vm.st if _, ok := output.(*bufio.Writer); !ok { output = bufio.NewWriter(output) defer output.(*bufio.Writer).Flush() } st.Reset() st.pc = bc st.output = output newvars := Vars(rvpool.Get()) defer rvpool.Release(newvars) defer newvars.Reset() st.vars = newvars if fc := vm.functions; fc != nil { for k, v := range vm.functions { st.vars[k] = v } } if vars != nil { for k, v := range vars { st.vars[k] = v } } st.Loader = vm.Loader // This is the main loop for op := st.CurrentOp(); op.Type() != TXOPEnd; op = st.CurrentOp() { op.Call(st) } }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/watch/watch.go#L204-L212
func CheckType(template proto.Message, val interface{}) error { if template != nil { valType, templateType := reflect.TypeOf(val), reflect.TypeOf(template) if valType != templateType { return fmt.Errorf("invalid type, got: %s, expected: %s", valType, templateType) } } return nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/pkg/io/opener.go#L72-L74
func IsNotExist(err error) bool { return os.IsNotExist(err) || err == storage.ErrObjectNotExist }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/layertree/easyjson.go#L906-L910
func (v *ProfileSnapshotParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoLayertree8(&r, v) return r.Error() }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/serviceworker/easyjson.go#L1611-L1615
func (v DeliverPushMessageParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoServiceworker17(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pps.go#L557-L566
func (c APIClient) DeletePipeline(name string, force bool) error { _, err := c.PpsAPIClient.DeletePipeline( c.Ctx(), &pps.DeletePipelineRequest{ Pipeline: NewPipeline(name), Force: force, }, ) return grpcutil.ScrubGRPC(err) }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/crc16/main.go#L112-L122
func Validate(data []byte, expected []byte) error { actual := Checksum(data) // validate the provided checksum against the calculated if !bytes.Equal(actual, expected) { return ErrInvalidChecksum } return nil }
https://github.com/janos/web/blob/0fb0203103deb84424510a8d5166ac00700f2b0e/templates/templates.go#L129-L134
func WithDelims(open, close string) Option { return func(o *Options) { o.delimOpen = open o.delimClose = close } }
https://github.com/profitbricks/profitbricks-sdk-go/blob/1d2db5f00bf5dd0b6c29273541c71c60cdf4d4d4/usermanagment.go#L246-L251
func (c *Client) ListGroupUsers(groupid string) (*Users, error) { url := umGroupUsers(groupid) + `?depth=` + c.client.depth + `&pretty=` + strconv.FormatBool(c.client.pretty) ret := &Users{} err := c.client.Get(url, ret, http.StatusOK) return ret, err }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/backend.go#L56-L65
func openSnapshotBackend(cfg ServerConfig, ss *snap.Snapshotter, snapshot raftpb.Snapshot) (backend.Backend, error) { snapPath, err := ss.DBFilePath(snapshot.Metadata.Index) if err != nil { return nil, fmt.Errorf("failed to find database snapshot file (%v)", err) } if err := os.Rename(snapPath, cfg.backendPath()); err != nil { return nil, fmt.Errorf("failed to rename database snapshot file (%v)", err) } return openBackend(cfg), nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/heapprofiler/easyjson.go#L691-L695
func (v *SamplingHeapProfileNode) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoHeapprofiler7(&r, v) return r.Error() }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/typed/buffer.go#L403-L407
func (ref Uint32Ref) Update(n uint32) { if ref != nil { binary.BigEndian.PutUint32(ref, n) } }
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L171-L182
func (db *DB) Count(column ...interface{}) *Function { switch len(column) { case 0, 1: // do nothing. default: panic(fmt.Errorf("Count: a number of argument must be 0 or 1, got %v", len(column))) } return &Function{ Name: "COUNT", Args: column, } }
https://github.com/rlmcpherson/s3gof3r/blob/864ae0bf7cf2e20c0002b7ea17f4d84fec1abc14/putter.go#L319-L334
func (p *putter) hashContent(r io.ReadSeeker) (string, string, string, error) { m := md5.New() s := sha256.New() mw := io.MultiWriter(m, s, p.md5) if _, err := io.Copy(mw, r); err != nil { return "", "", "", err } md5Sum := m.Sum(nil) shaSum := hex.EncodeToString(s.Sum(nil)) etag := hex.EncodeToString(md5Sum) // add to checksum of all parts for verification on upload completion if _, err := p.md5OfParts.Write(md5Sum); err != nil { return "", "", "", err } return base64.StdEncoding.EncodeToString(md5Sum), shaSum, etag, nil }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L5129-L5138
func (u LedgerKey) GetOffer() (result LedgerKeyOffer, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) if armName == "Offer" { result = *u.Offer ok = true } return }
https://github.com/pivotal-pez/pezdispenser/blob/768e2777520868857916b66cfd4cfb7149383ca5/innkeeperclient/ik_client.go#L70-L77
func (s *IkClient) ProvisionHost(sku string, tenantid string) (info *ProvisionHostResponse, err error) { info = new(ProvisionHostResponse) qp := url.Values{} qp.Add("sku", sku) qp.Add("tenantid", tenantid) err = s.Call(RouteProvisionHost, qp, info) return }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pod-utils/clone/format.go#L26-L55
func FormatRecord(record Record) string { output := bytes.Buffer{} if record.Failed { fmt.Fprintln(&output, "# FAILED!") } fmt.Fprintf(&output, "# Cloning %s/%s at %s", record.Refs.Org, record.Refs.Repo, record.Refs.BaseRef) if record.Refs.BaseSHA != "" { fmt.Fprintf(&output, "(%s)", record.Refs.BaseSHA) } output.WriteString("\n") if len(record.Refs.Pulls) > 0 { output.WriteString("# Checking out pulls:\n") for _, pull := range record.Refs.Pulls { fmt.Fprintf(&output, "#\t%d", pull.Number) if pull.SHA != "" { fmt.Fprintf(&output, "(%s)", pull.SHA) } fmt.Fprint(&output, "\n") } } for _, command := range record.Commands { fmt.Fprintf(&output, "$ %s\n", command.Command) fmt.Fprint(&output, command.Output) if command.Error != "" { fmt.Fprintf(&output, "# Error: %s\n", command.Error) } } return output.String() }
https://github.com/segmentio/objconv/blob/7a1d7b8e6f3551b30751e6b2ea6bae500883870e/resp/error.go#L24-L41
func (e *Error) Type() string { s := e.Error() if i := strings.IndexByte(s, ' '); i < 0 { s = "" } else { s = s[:i] for _, c := range s { if !unicode.IsUpper(c) { s = "" break } } } return s }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/compare.go#L117-L120
func (cmp Cmp) WithPrefix() Cmp { cmp.RangeEnd = getPrefix(cmp.Key) return cmp }
https://github.com/gravitational/roundtrip/blob/e1e0cd6b05a6bb1791b262e63160038828fd7b3a/client.go#L341-L348
func (c *Client) DeleteWithParams(ctx context.Context, endpoint string, params url.Values) (*Response, error) { baseURL, err := url.Parse(endpoint) if err != nil { return nil, err } baseURL.RawQuery = params.Encode() return c.Delete(ctx, baseURL.String()) }
https://github.com/ipfs/go-ipfs-api/blob/a1b28da48b3763f67654ec4cfcba5fcbfb3dfb32/ipns.go#L14-L23
func (s *Shell) Publish(node string, value string) error { var pubResp PublishResponse req := s.Request("name/publish") if node != "" { req.Arguments(node) } req.Arguments(value) return req.Exec(context.Background(), &pubResp) }
https://github.com/ipfs/go-ipfs-api/blob/a1b28da48b3763f67654ec4cfcba5fcbfb3dfb32/shell.go#L339-L349
func (s *Shell) Version() (string, string, error) { ver := struct { Version string Commit string }{} if err := s.Request("version").Exec(context.Background(), &ver); err != nil { return "", "", err } return ver.Version, ver.Commit, nil }
https://github.com/armon/go-radix/blob/1a2de0c21c94309923825da3df33a4381872c795/radix.go#L486-L513
func (t *Tree) WalkPath(path string, fn WalkFn) { n := t.root search := path for { // Visit the leaf values if any if n.leaf != nil && fn(n.leaf.key, n.leaf.val) { return } // Check for key exhaution if len(search) == 0 { return } // Look for an edge n = n.getEdge(search[0]) if n == nil { return } // Consume the search prefix if strings.HasPrefix(search, n.prefix) { search = search[len(n.prefix):] } else { break } } }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/peribolos/main.go#L700-L711
func updateBool(have, want *bool) bool { switch { case have == nil: panic("have must not be nil") case want == nil: return false // do not care what we have case *have == *want: return false //already have it } *have = *want // update value return true }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/app.go#L1387-L1417
func restart(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) { process := InputValue(r, "process") appName := r.URL.Query().Get(":app") a, err := getAppFromContext(appName, r) if err != nil { return err } allowed := permission.Check(t, permission.PermAppUpdateRestart, contextsForApp(&a)..., ) if !allowed { return permission.ErrUnauthorized } evt, err := event.New(&event.Opts{ Target: appTarget(appName), Kind: permission.PermAppUpdateRestart, Owner: t, CustomData: event.FormToCustomData(InputFields(r)), Allowed: event.Allowed(permission.PermAppReadEvents, contextsForApp(&a)...), }) if err != nil { return err } defer func() { evt.Done(err) }() w.Header().Set("Content-Type", "application/x-json-stream") keepAliveWriter := tsuruIo.NewKeepAliveWriter(w, 30*time.Second, "") defer keepAliveWriter.Stop() writer := &tsuruIo.SimpleJsonMessageEncoderWriter{Encoder: json.NewEncoder(keepAliveWriter)} evt.SetLogWriter(writer) return a.Restart(process, evt) }
https://github.com/coryb/figtree/blob/e5fa026ccd54e0a6a99b6d81f73bfcc8e6fe6a6b/convert.go#L9-L91
func convertString(src string, dst interface{}) (err error) { switch v := dst.(type) { case *bool: *v, err = strconv.ParseBool(src) case *string: *v = src case *int: var tmp int64 // this is a cheat, we only know int is at least 32 bits // but we have to make a compromise here tmp, err = strconv.ParseInt(src, 10, 32) *v = int(tmp) case *int8: var tmp int64 tmp, err = strconv.ParseInt(src, 10, 8) *v = int8(tmp) case *int16: var tmp int64 tmp, err = strconv.ParseInt(src, 10, 16) *v = int16(tmp) case *int32: var tmp int64 tmp, err = strconv.ParseInt(src, 10, 32) *v = int32(tmp) case *int64: var tmp int64 tmp, err = strconv.ParseInt(src, 10, 64) *v = int64(tmp) case *uint: var tmp uint64 // this is a cheat, we only know uint is at least 32 bits // but we have to make a compromise here tmp, err = strconv.ParseUint(src, 10, 32) *v = uint(tmp) case *uint8: var tmp uint64 tmp, err = strconv.ParseUint(src, 10, 8) *v = uint8(tmp) case *uint16: var tmp uint64 tmp, err = strconv.ParseUint(src, 10, 16) *v = uint16(tmp) case *uint32: var tmp uint64 tmp, err = strconv.ParseUint(src, 10, 32) *v = uint32(tmp) case *uint64: var tmp uint64 tmp, err = strconv.ParseUint(src, 10, 64) *v = uint64(tmp) // hmm, collides with uint8 // case *byte: // tmp := []byte(src) // if len(tmp) == 1 { // *v = tmp[0] // } else { // err = fmt.Errorf("Cannot convert string %q to byte, length: %d", src, len(tmp)) // } // hmm, collides with int32 // case *rune: // tmp := []rune(src) // if len(tmp) == 1 { // *v = tmp[0] // } else { // err = fmt.Errorf("Cannot convert string %q to rune, lengt: %d", src, len(tmp)) // } case *float32: var tmp float64 tmp, err = strconv.ParseFloat(src, 32) *v = float32(tmp) case *float64: var tmp float64 tmp, err = strconv.ParseFloat(src, 64) *v = float64(tmp) default: err = fmt.Errorf("Cannot convert string %q to type %T", src, dst) } if err != nil { return err } return nil }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/arena.go#L117-L119
func (s *Arena) getKey(offset uint32, size uint16) []byte { return s.buf[offset : offset+uint32(size)] }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/mvcc/index.go#L157-L185
func (ti *treeIndex) RangeSince(key, end []byte, rev int64) []revision { keyi := &keyIndex{key: key} ti.RLock() defer ti.RUnlock() if end == nil { item := ti.tree.Get(keyi) if item == nil { return nil } keyi = item.(*keyIndex) return keyi.since(ti.lg, rev) } endi := &keyIndex{key: end} var revs []revision ti.tree.AscendGreaterOrEqual(keyi, func(item btree.Item) bool { if len(endi.key) > 0 && !item.Less(endi) { return false } curKeyi := item.(*keyIndex) revs = append(revs, curKeyi.since(ti.lg, rev)...) return true }) sort.Sort(revisions(revs)) return revs }
https://github.com/jhillyerd/enmime/blob/874cc30e023f36bd1df525716196887b0f04851b/part.go#L141-L161
func (p *Part) setupContentHeaders(mediaParams map[string]string) { // Determine content disposition, filename, character set. disposition, dparams, _, err := parseMediaType(p.Header.Get(hnContentDisposition)) if err == nil { // Disposition is optional p.Disposition = disposition p.FileName = decodeHeader(dparams[hpFilename]) } if p.FileName == "" && mediaParams[hpName] != "" { p.FileName = decodeHeader(mediaParams[hpName]) } if p.FileName == "" && mediaParams[hpFile] != "" { p.FileName = decodeHeader(mediaParams[hpFile]) } if p.Charset == "" { p.Charset = mediaParams[hpCharset] } if p.FileModDate.IsZero() { p.FileModDate, _ = time.Parse(time.RFC822, mediaParams[hpModDate]) } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/mapping.go#L168-L182
func (f *Field) Column() string { if f.Type.Code != TypeColumn { panic("attempt to get column name of non-column field") } column := lex.Snake(f.Name) join := f.Config.Get("join") if join != "" { column = fmt.Sprintf("%s AS %s", join, column) } return column }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/http.go#L29-L46
func WriteJSON(w http.ResponseWriter, body interface{}, debug bool) error { var output io.Writer var captured *bytes.Buffer output = w if debug { captured = &bytes.Buffer{} output = io.MultiWriter(w, captured) } err := json.NewEncoder(output).Encode(body) if captured != nil { shared.DebugJson(captured) } return err }
https://github.com/libp2p/go-libp2p-routing/blob/15c28e7faa25921fd1160412003fecdc70e09a5c/options/options.go#L26-L37
func (opts *Options) ToOption() Option { return func(nopts *Options) error { *nopts = *opts if opts.Other != nil { nopts.Other = make(map[interface{}]interface{}, len(opts.Other)) for k, v := range opts.Other { nopts.Other[k] = v } } return nil } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/raft/raft.go#L583-L590
func (r *raft) bcastHeartbeat() { lastCtx := r.readOnly.lastPendingRequestCtx() if len(lastCtx) == 0 { r.bcastHeartbeatWithCtx(nil) } else { r.bcastHeartbeatWithCtx([]byte(lastCtx)) } }
https://github.com/sclevine/agouti/blob/96599c91888f1b1cf2dccc7f1776ba7f511909e5/selectable.go#L151-L153
func (s *selectable) AllByXPath(selector string) *MultiSelection { return newMultiSelection(s.session, s.selectors.Append(target.XPath, selector)) }
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/sequence.go#L327-L332
func (s *FileSequence) InvertedFrameRangePadded() string { if s.frameSet == nil { return "" } return s.frameSet.InvertedFrameRange(s.zfill) }
https://github.com/brankas/sentinel/blob/0ff081867c31a45cb71f5976ea6144fd06a557b5/util.go#L25-L51
func convertAndAppendContextFuncs(o []func(context.Context) error, v ...interface{}) ([]func(context.Context) error, error) { for _, z := range v { var t func(context.Context) error switch f := z.(type) { case func(context.Context) error: t = f case func(): t = func(context.Context) error { f() return nil } case func() error: t = func(context.Context) error { return f() } } if t == nil { return nil, ErrInvalidType } o = append(o, t) } return o, nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/runtime/easyjson.go#L5510-L5514
func (v AwaitPromiseParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoRuntime51(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/snapshot.go#L47-L66
func (s *Snapshot) Description() (string, error) { var err C.VixError = C.VIX_OK var desc *C.char err = C.get_property(s.handle, C.VIX_PROPERTY_SNAPSHOT_DESCRIPTION, unsafe.Pointer(&desc)) defer C.Vix_FreeBuffer(unsafe.Pointer(desc)) if C.VIX_OK != err { return "", &Error{ Operation: "snapshot.Description", Code: int(err & 0xFFFF), Text: C.GoString(C.Vix_GetErrorText(err, nil)), } } return C.GoString(desc), nil }
https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/syslog.go#L20-L24
func NewSyslogBackend(prefix string) (b *SyslogBackend, err error) { var w *syslog.Writer w, err = syslog.New(syslog.LOG_CRIT, prefix) return &SyslogBackend{w}, err }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/slices.go#L58-L76
func SelectStrings(tx *sql.Tx, query string, args ...interface{}) ([]string, error) { values := []string{} scan := func(rows *sql.Rows) error { var value string err := rows.Scan(&value) if err != nil { return err } values = append(values, value) return nil } err := scanSingleColumn(tx, query, args, "TEXT", scan) if err != nil { return nil, err } return values, nil }
https://github.com/bazelbuild/bazel-gazelle/blob/e3805aaca69a9deb949b47bfc45b9b1870712f4f/rule/rule.go#L551-L569
func NewRule(kind, name string) *Rule { nameAttr := &bzl.AssignExpr{ LHS: &bzl.Ident{Name: "name"}, RHS: &bzl.StringExpr{Value: name}, Op: "=", } r := &Rule{ stmt: stmt{ expr: &bzl.CallExpr{ X: &bzl.Ident{Name: kind}, List: []bzl.Expr{nameAttr}, }, }, kind: kind, attrs: map[string]*bzl.AssignExpr{"name": nameAttr}, private: map[string]interface{}{}, } return r }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/rbac/server.go#L130-L166
func (r *Server) SyncProjects() error { if r.ProjectsFunc == nil { return fmt.Errorf("ProjectsFunc isn't configured yet, cannot sync") } resources := []rbacResource{} resourcesMap := map[string]string{} // Get all projects projects, err := r.ProjectsFunc() if err != nil { return err } // Convert to RBAC format for id, name := range projects { resources = append(resources, rbacResource{ Name: name, Identifier: strconv.FormatInt(id, 10), }) resourcesMap[name] = strconv.FormatInt(id, 10) } // Update RBAC err = r.postResources(resources, nil, true) if err != nil { return err } // Update project map r.resourcesLock.Lock() r.resources = resourcesMap r.resourcesLock.Unlock() return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/domsnapshot/easyjson.go#L1271-L1275
func (v NameValue) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDomsnapshot5(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/ipfs/go-ipfs-api/blob/a1b28da48b3763f67654ec4cfcba5fcbfb3dfb32/requestbuilder.go#L85-L100
func (r *RequestBuilder) Exec(ctx context.Context, res interface{}) error { httpRes, err := r.Send(ctx) if err != nil { return err } if res == nil { lateErr := httpRes.Close() if httpRes.Error != nil { return httpRes.Error } return lateErr } return httpRes.Decode(res) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L3523-L3527
func (v *ResourceTiming) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoNetwork23(&r, v) return r.Error() }
https://github.com/mikespook/possum/blob/56d7ebb6470b670001632b11be7fc089038f4dd7/view/template.go#L40-L43
func InitHtmlTemplates(pattern string) (err error) { htmlTemp.Template, err = html.ParseGlob(pattern) return }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/crds/client.go#L261-L269
func (c *dummyClient) List(opts v1.ListOptions) (Collection, error) { var items []Object for _, i := range c.objects { items = append(items, i) } r := c.NewCollection() r.SetItems(items) return r, nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/backup.go#L28-L52
func backupLoadByName(s *state.State, project, name string) (*backup, error) { // Get the backup database record args, err := s.Cluster.ContainerGetBackup(project, name) if err != nil { return nil, errors.Wrap(err, "Load backup from database") } // Load the container it belongs to c, err := containerLoadById(s, args.ContainerID) if err != nil { return nil, errors.Wrap(err, "Load container from database") } // Return the backup struct return &backup{ state: s, container: c, id: args.ID, name: name, creationDate: args.CreationDate, expiryDate: args.ExpiryDate, containerOnly: args.ContainerOnly, optimizedStorage: args.OptimizedStorage, }, nil }
https://github.com/lestrrat-go/xslate/blob/6a6eb0fce8ab7407a3e0460af60758e5d6f2b9f8/parser/symbols.go#L103-L125
func (l *LexSymbolSet) GetSortedList() LexSymbolList { // Because symbols are parsed automatically in a loop, we need to make // sure that we search starting with the longest term (e.g., "INCLUDE" // must come before "IN") // However, simply sorting the symbols using alphabetical sort then // max-length forces us to make more comparisons than necessary. // To get the best of both world, we allow passing a floating point // "priority" parameter to sort the symbols if l.SortedList != nil { return l.SortedList } num := len(l.Map) list := make(LexSymbolList, num) i := 0 for _, v := range l.Map { list[i] = v i++ } l.SortedList = list.Sort() return l.SortedList }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L1491-L1495
func (v SearchInResourceParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoPage16(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/blockade/blockade.go#L223-L233
func calculateBlocks(changes []github.PullRequestChange, blockades []blockade) summary { sum := make(summary) for _, change := range changes { for _, b := range blockades { if b.isBlocked(change.Filename) { sum[b.explanation] = append(sum[b.explanation], change) } } } return sum }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/signature/mechanism_gpgme.go#L66-L83
func newGPGMEContext(optionalDir string) (*gpgme.Context, error) { ctx, err := gpgme.New() if err != nil { return nil, err } if err = ctx.SetProtocol(gpgme.ProtocolOpenPGP); err != nil { return nil, err } if optionalDir != "" { err := ctx.SetEngineInfo(gpgme.ProtocolOpenPGP, "", optionalDir) if err != nil { return nil, err } } ctx.SetArmor(false) ctx.SetTextMode(false) return ctx, nil }
https://github.com/geoffgarside/ber/blob/27a1aff36ce64dbe5d93c08cc5f161983134ddc5/common.go#L61-L105
func parseFieldParameters(str string) (ret fieldParameters) { for _, part := range strings.Split(str, ",") { switch { case part == "optional": ret.optional = true case part == "explicit": ret.explicit = true if ret.tag == nil { ret.tag = new(int) } case part == "generalized": ret.timeType = tagGeneralizedTime case part == "utc": ret.timeType = tagUTCTime case part == "ia5": ret.stringType = tagIA5String case part == "printable": ret.stringType = tagPrintableString case part == "utf8": ret.stringType = tagUTF8String case strings.HasPrefix(part, "default:"): i, err := strconv.ParseInt(part[8:], 10, 64) if err == nil { ret.defaultValue = new(int64) *ret.defaultValue = i } case strings.HasPrefix(part, "tag:"): i, err := strconv.Atoi(part[4:]) if err == nil { ret.tag = new(int) *ret.tag = i } case part == "set": ret.set = true case part == "application": ret.application = true if ret.tag == nil { ret.tag = new(int) } case part == "omitempty": ret.omitEmpty = true } } return }
https://github.com/glycerine/rbuf/blob/75b78581bebe959bc9a3df4c5f64e82c187d7531/rbuf.go#L157-L159
func (b *FixedSizeRingBuf) Read(p []byte) (n int, err error) { return b.ReadAndMaybeAdvance(p, true) }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/coal/catalog.go#L63-L193
func (c *Catalog) Visualize(title string) string { // prepare buffer var out bytes.Buffer // start graph out.WriteString("graph G {\n") out.WriteString(" rankdir=\"LR\";\n") out.WriteString(" sep=\"0.3\";\n") out.WriteString(" ranksep=\"0.5\";\n") out.WriteString(" nodesep=\"0.4\";\n") out.WriteString(" pad=\"0.4,0.4\";\n") out.WriteString(" margin=\"0,0\";\n") out.WriteString(" labelloc=\"t\";\n") out.WriteString(" fontsize=\"13\";\n") out.WriteString(" fontname=\"Arial BoldMT\";\n") out.WriteString(" splines=\"spline\";\n") out.WriteString(" overlap=\"voronoi\";\n") out.WriteString(" outputorder=\"edgesfirst\";\n") out.WriteString(" edge[headclip=true, tailclip=false];\n") out.WriteString(" label=\"" + title + "\";\n") // get a sorted list of model names and lookup table var names []string lookup := make(map[string]string) for name, model := range c.models { names = append(names, name) lookup[name] = model.Meta().Name } sort.Strings(names) // add model nodes for _, name := range names { // get model model := c.models[name] // write begin of node out.WriteString(fmt.Sprintf(` "%s" [ style=filled, fillcolor=white, label=`, lookup[name])) // write head table out.WriteString(fmt.Sprintf(`<<table border="0" align="center" cellspacing="0.5" cellpadding="0" width="134"><tr><td align="center" valign="bottom" width="130"><font face="Arial BoldMT" point-size="11">%s</font></td></tr></table>|`, lookup[name])) // write begin of tail table out.WriteString(fmt.Sprintf(`<table border="0" align="left" cellspacing="2" cellpadding="0" width="134">`)) // write attributes for _, field := range model.Meta().OrderedFields { out.WriteString(fmt.Sprintf(`<tr><td align="left" width="130" port="%s">%s<font face="Arial ItalicMT" color="grey60"> %s</font></td></tr>`, field.Name, field.Name, field.Type.String())) } // write end of tail table out.WriteString(fmt.Sprintf(`</table>>`)) // write end of node out.WriteString(`, shape=Mrecord, fontsize=10, fontname="ArialMT", margin="0.07,0.05", penwidth="1.0" ];` + "\n") } // define temporary struct type rel struct { from, to string srcMany bool dstMany bool hasInverse bool } // prepare list list := make(map[string]*rel) var relNames []string // prepare relationships for _, name := range names { // get model model := c.models[name] // add all direct relationships for _, field := range model.Meta().OrderedFields { if field.RelName != "" && (field.ToOne || field.ToMany) { list[name+"-"+field.RelName] = &rel{ from: name, to: field.RelType, srcMany: field.ToMany, } relNames = append(relNames, name+"-"+field.RelName) } } } // update relationships for _, name := range names { // get model model := c.models[name] // add all indirect relationships for _, field := range model.Meta().OrderedFields { if field.RelName != "" && (field.HasOne || field.HasMany) { r := list[field.RelType+"-"+field.RelInverse] r.dstMany = field.HasMany r.hasInverse = true } } } // sort relationship names sort.Strings(relNames) // add relationships for _, name := range relNames { // get relationship r := list[name] // get style style := "solid" if !r.hasInverse { style = "dotted" } // get color color := "black" if r.srcMany { color = "black:white:black" } // write edge out.WriteString(fmt.Sprintf(` "%s"--"%s"[ fontname="ArialMT", fontsize=7, dir=both, arrowsize="0.9", penwidth="0.9", labelangle=32, labeldistance="1.8", style=%s, color="%s", arrowhead=%s, arrowtail=%s ];`, lookup[r.from], lookup[r.to], style, color, "normal", "none") + "\n") } // end graph out.WriteString("}\n") return out.String() }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/examples/keyvalue/server/server.go#L127-L137
func (h *kvHandler) ClearAll(ctx thrift.Context) error { if !isAdmin(ctx) { return &keyvalue.NotAuthorized{} } h.Lock() defer h.Unlock() h.vals = make(map[string]string) return nil }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/skl/skl.go#L480-L486
func (s *UniIterator) Next() { if !s.reversed { s.iter.Next() } else { s.iter.Prev() } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/retry.go#L191-L195
func RetryMaintenanceClient(c *Client, conn *grpc.ClientConn) pb.MaintenanceClient { return &retryMaintenanceClient{ mc: pb.NewMaintenanceClient(conn), } }
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/tcqueue/tcqueue.go#L397-L401
func (queue *Queue) ClaimTask(taskId, runId string, payload *TaskClaimRequest) (*TaskClaimResponse, error) { cd := tcclient.Client(*queue) responseObject, _, err := (&cd).APICall(payload, "POST", "/task/"+url.QueryEscape(taskId)+"/runs/"+url.QueryEscape(runId)+"/claim", new(TaskClaimResponse), nil) return responseObject.(*TaskClaimResponse), err }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/signature/policy_reference_match.go#L14-L25
func parseImageAndDockerReference(image types.UnparsedImage, s2 string) (reference.Named, reference.Named, error) { r1 := image.Reference().DockerReference() if r1 == nil { return nil, nil, PolicyRequirementError(fmt.Sprintf("Docker reference match attempted on image %s with no known Docker reference identity", transports.ImageName(image.Reference()))) } r2, err := reference.ParseNormalizedNamed(s2) if err != nil { return nil, nil, err } return r1, r2, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/pubsub/subscriber/server.go#L148-L155
func (c *pubSubClient) new(ctx context.Context, project string) (pubsubClientInterface, error) { client, err := pubsub.NewClient(ctx, project) if err != nil { return nil, err } c.client = client return c, nil }