_id
stringlengths
86
170
text
stringlengths
54
39.3k
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L3726-L3729
func (e ManageDataResultCode) String() string { name, _ := manageDataResultCodeMap[int32(e)] return name }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/types/urlsmap.go#L45-L55
func NewURLsMapFromStringMap(m map[string]string, sep string) (URLsMap, error) { var err error um := URLsMap{} for k, v := range m { um[k], err = NewURLs(strings.Split(v, sep)) if err != nil { return nil, err } } return um, nil }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/backoff/backoff.go#L81-L83
func (b *ConstantBackOff) GetElapsedTime() time.Duration { return time.Now().Sub(b.startTime) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/task/schedule.go#L33-L47
func Every(interval time.Duration, options ...EveryOption) Schedule { every := &every{} for _, option := range options { option(every) } first := true return func() (time.Duration, error) { var err error if first && every.skipFirst { err = ErrSkip } first = false return interval, err } }
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/errors/type.go#L116-L125
func (t *Type) UnmarshalText(text []byte) error { e, err := fromString(string(text)) if err != nil { return err } *t = e return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/clientv3/utils.go#L31-L34
func jitterUp(duration time.Duration, jitter float64) time.Duration { multiplier := jitter * (rand.Float64()*2 - 1) return time.Duration(float64(duration) * (1 + multiplier)) }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L8885-L8892
func (r *ResourceGroup) Locator(api *API) *ResourceGroupLocator { for _, l := range r.Links { if l["rel"] == "self" { return api.ResourceGroupLocator(l["href"]) } } return nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/cluster/raft.go#L239-L250
func (i *raftInstance) Servers() ([]raft.Server, error) { if i.raft.State() != raft.Leader { return nil, raft.ErrNotLeader } future := i.raft.GetConfiguration() err := future.Error() if err != nil { return nil, err } configuration := future.Configuration() return configuration.Servers, nil }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/set_options.go#L66-L70
func (m InflationDest) MutateSetOptions(o *xdr.SetOptionsOp) (err error) { o.InflationDest = &xdr.AccountId{} err = setAccountId(string(m), o.InflationDest) return }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/mock/mockserver/mockserver.go#L64-L73
func StartMockServersOnNetwork(count int, network string) (ms *MockServers, err error) { switch network { case "tcp": return startMockServersTcp(count) case "unix": return startMockServersUnix(count) default: return nil, fmt.Errorf("unsupported network type: %s", network) } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/fetch/fetch.go#L96-L98
func (p *FailRequestParams) Do(ctx context.Context) (err error) { return cdp.Execute(ctx, CommandFailRequest, p, nil) }
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/grpc/ttnctx/context.go#L73-L79
func IDFromMetadata(md metadata.MD) (string, error) { id, ok := md["id"] if !ok || len(id) == 0 { return "", ErrNoID } return id[0], nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/easyjson.go#L7178-L7182
func (v *CaptureScreenshotReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoPage79(&r, v) return r.Error() }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/level_handler.go#L194-L227
func (s *levelHandler) getTableForKey(key []byte) ([]*table.Table, func() error) { s.RLock() defer s.RUnlock() if s.level == 0 { // For level 0, we need to check every table. Remember to make a copy as s.tables may change // once we exit this function, and we don't want to lock s.tables while seeking in tables. // CAUTION: Reverse the tables. out := make([]*table.Table, 0, len(s.tables)) for i := len(s.tables) - 1; i >= 0; i-- { out = append(out, s.tables[i]) s.tables[i].IncrRef() } return out, func() error { for _, t := range out { if err := t.DecrRef(); err != nil { return err } } return nil } } // For level >= 1, we can do a binary search as key range does not overlap. idx := sort.Search(len(s.tables), func(i int) bool { return y.CompareKeys(s.tables[i].Biggest(), key) >= 0 }) if idx >= len(s.tables) { // Given key is strictly > than every element we have. return nil, func() error { return nil } } tbl := s.tables[idx] tbl.IncrRef() return []*table.Table{tbl}, tbl.DecrRef }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/node/open.go#L29-L63
func EnsureSchema(db *sql.DB, dir string, hook schema.Hook) (int, error) { backupDone := false schema := Schema() schema.File(filepath.Join(dir, "patch.local.sql")) // Optional custom queries schema.Hook(func(version int, tx *sql.Tx) error { if !backupDone { logger.Infof("Updating the LXD database schema. Backup made as \"local.db.bak\"") path := filepath.Join(dir, "local.db") err := shared.FileCopy(path, path+".bak") if err != nil { return err } backupDone = true } if version == -1 { logger.Debugf("Running pre-update queries from file for local DB schema") } else { logger.Debugf("Updating DB schema from %d to %d", version, version+1) } // Run the given hook only against actual update versions, not // when a custom query file is passed (signaled by version == -1). if hook != nil && version != -1 { err := hook(version, tx) if err != nil { } } return nil }) return schema.Ensure(db) }
https://github.com/naoina/genmai/blob/78583835e1e41e3938e1ddfffd7101f8ad27fae0/genmai.go#L298-L342
func (db *DB) Update(obj interface{}) (affected int64, err error) { rv, rtype, tableName, err := db.tableValueOf("Update", obj) if err != nil { return -1, err } if hook, ok := obj.(BeforeUpdater); ok { if err := hook.BeforeUpdate(); err != nil { return -1, err } } fieldIndexes := db.collectFieldIndexes(rtype, nil) pkIdx := db.findPKIndex(rtype, nil) if len(pkIdx) < 1 { return -1, fmt.Errorf(`Update: fields of struct doesn't have primary key: "pk" struct tag must be specified for update`) } sets := make([]string, len(fieldIndexes)) var args []interface{} for i, index := range fieldIndexes { col := db.columnFromTag(rtype.FieldByIndex(index)) sets[i] = fmt.Sprintf("%s = %s", db.dialect.Quote(col), db.dialect.PlaceHolder(i)) args = append(args, rv.FieldByIndex(index).Interface()) } query := fmt.Sprintf("UPDATE %s SET %s WHERE %s = %s", db.dialect.Quote(tableName), strings.Join(sets, ", "), db.dialect.Quote(db.columnFromTag(rtype.FieldByIndex(pkIdx))), db.dialect.PlaceHolder(len(fieldIndexes))) args = append(args, rv.FieldByIndex(pkIdx).Interface()) stmt, err := db.prepare(query, args...) if err != nil { return -1, err } defer stmt.Close() result, err := stmt.Exec(args...) if err != nil { return -1, err } affected, _ = result.RowsAffected() if hook, ok := obj.(AfterUpdater); ok { if err := hook.AfterUpdate(); err != nil { return affected, err } } return affected, nil }
https://github.com/libp2p/go-libp2p-crypto/blob/9d2fed53443f745e6dc4d02bdcc94d9742a0ca84/secp256k1.go#L31-L38
func UnmarshalSecp256k1PrivateKey(data []byte) (PrivKey, error) { if len(data) != btcec.PrivKeyBytesLen { return nil, fmt.Errorf("expected secp256k1 data size to be %d", btcec.PrivKeyBytesLen) } privk, _ := btcec.PrivKeyFromBytes(btcec.S256(), data) return (*Secp256k1PrivateKey)(privk), nil }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L113-L116
func (img *IplImage) Clone() *IplImage { p := C.cvCloneImage((*C.IplImage)(img)) return (*IplImage)(p) }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/inmem_snapshot.go#L66-L74
func (m *InmemSnapshotStore) List() ([]*SnapshotMeta, error) { m.RLock() defer m.RUnlock() if !m.hasSnapshot { return []*SnapshotMeta{}, nil } return []*SnapshotMeta{&m.latest.meta}, nil }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/client/informers/externalversions/generic.go#L53-L62
func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=prow.k8s.io, Version=v1 case v1.SchemeGroupVersion.WithResource("prowjobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Prow().V1().ProwJobs().Informer()}, nil } return nil, fmt.Errorf("no informer found for %v", resource) }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/cast/easyjson.go#L81-L85
func (v *StopCastingParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoCast(&r, v) return r.Error() }
https://github.com/DamienFontaine/lunarc/blob/2e7332a51f554794a549a313430eaa7dec8d13cc/security/controller.go#L78-L81
func NewOAuth2Controller(am ApplicationManager, cnf web.Config) *OAuth2Controller { oAuth2Controller := OAuth2Controller{cnf: cnf, ApplicationManager: am} return &oAuth2Controller }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/boskos/mason/client.go#L77-L105
func (c *Client) ReleaseOne(name, dest string) (allErrors error) { res, err := c.getResource(name) if err != nil { allErrors = err return } resourceNames := []string{name} var leasedResources common.LeasedResources if err := res.UserData.Extract(LeasedResources, &leasedResources); err != nil { if _, ok := err.(*common.UserDataNotFound); !ok { logrus.WithError(err).Errorf("cannot parse %s from User Data", LeasedResources) allErrors = multierror.Append(allErrors, err) if err := c.basic.ReleaseOne(name, dest); err != nil { logrus.WithError(err).Warningf("failed to release resource %s", name) allErrors = multierror.Append(allErrors, err) } return } } resourceNames = append(resourceNames, leasedResources...) for _, n := range resourceNames { if err := c.basic.ReleaseOne(n, dest); err != nil { logrus.WithError(err).Warningf("failed to release resource %s", n) allErrors = multierror.Append(allErrors, err) } } c.deleteResource(name) return }
https://github.com/uber/tchannel-go/blob/3c9ced6d946fe2fec6c915703a533e966c09e07a/introspection.go#L374-L382
func (r *Relayer) IntrospectState(opts *IntrospectionOptions) RelayerRuntimeState { count := r.inbound.Count() + r.outbound.Count() return RelayerRuntimeState{ Count: count, InboundItems: r.inbound.IntrospectState(opts, "inbound"), OutboundItems: r.outbound.IntrospectState(opts, "outbound"), MaxTimeout: r.maxTimeout, } }
https://github.com/guregu/null/blob/80515d440932108546bcade467bb7d6968e812e2/bool.go#L74-L90
func (b *Bool) UnmarshalText(text []byte) error { str := string(text) switch str { case "", "null": b.Valid = false return nil case "true": b.Bool = true case "false": b.Bool = false default: b.Valid = false return errors.New("invalid input:" + str) } b.Valid = true return nil }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/etcdhttp/metrics.go#L48-L64
func NewHealthHandler(hfunc func() Health) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodGet { w.Header().Set("Allow", http.MethodGet) http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed) return } h := hfunc() d, _ := json.Marshal(h) if h.Health != "true" { http.Error(w, string(d), http.StatusServiceUnavailable) return } w.WriteHeader(http.StatusOK) w.Write(d) } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/easyjson.go#L1680-L1684
func (v *ClearDeviceMetricsOverrideParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoEmulation19(&r, v) return r.Error() }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/image/memory.go#L63-L65
func (i *memoryImage) LayerInfosForCopy(ctx context.Context) ([]types.BlobInfo, error) { return nil, nil }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/log15/stack/stack.go#L168-L173
func (pcs Trace) TrimBelow(pc Call) Trace { for len(pcs) > 0 && pcs[0] != pc { pcs = pcs[1:] } return pcs }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/api/pool.go#L146-L177
func removePoolHandler(w http.ResponseWriter, r *http.Request, t auth.Token) (err error) { allowed := permission.Check(t, permission.PermPoolDelete) if !allowed { return permission.ErrUnauthorized } poolName := r.URL.Query().Get(":name") filter := &app.Filter{} filter.Pool = poolName apps, err := app.List(appFilterByContext([]permTypes.PermissionContext{}, filter)) if err != nil { return err } if len(apps) > 0 { return &terrors.HTTP{Code: http.StatusForbidden, Message: "This pool has apps, you need to migrate or remove them before removing the pool"} } evt, err := event.New(&event.Opts{ Target: event.Target{Type: event.TargetTypePool, Value: poolName}, Kind: permission.PermPoolDelete, Owner: t, CustomData: event.FormToCustomData(InputFields(r)), Allowed: event.Allowed(permission.PermPoolReadEvents, permission.Context(permTypes.CtxPool, poolName)), }) if err != nil { return err } defer func() { evt.Done(err) }() err = pool.RemovePool(poolName) if err == pool.ErrPoolNotFound { return &terrors.HTTP{Code: http.StatusNotFound, Message: err.Error()} } return err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/fetcher.go#L41-L47
func NewFetcher(repository string) *Fetcher { return &Fetcher{ IssuesChannel: make(chan sql.Issue, 100), EventsCommentsChannel: make(chan interface{}, 100), repository: repository, } }
https://github.com/google/go-cmp/blob/6f77996f0c42f7b84e5a2b252227263f93432e9b/cmp/compare.go#L194-L207
func (s *state) statelessCompare(step PathStep) diff.Result { // We do not save and restore the curPath because all of the compareX // methods should properly push and pop from the path. // It is an implementation bug if the contents of curPath differs from // when calling this function to when returning from it. oldResult, oldReporters := s.result, s.reporters s.result = diff.Result{} // Reset result s.reporters = nil // Remove reporters to avoid spurious printouts s.compareAny(step) res := s.result s.result, s.reporters = oldResult, oldReporters return res }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/server/pkg/deploy/assets/assets.go#L1547-L1552
func WriteMicrosoftAssets(encoder Encoder, opts *AssetOpts, container string, id string, secret string, volumeSize int) error { if err := WriteAssets(encoder, opts, microsoftBackend, microsoftBackend, volumeSize, ""); err != nil { return err } return WriteSecret(encoder, MicrosoftSecret(container, id, secret), opts) }
https://github.com/mgutz/str/blob/968bf66e3da857419e4f6e71b2d5c9ae95682dc4/funcsPZ.go#L97-L101
func ReplacePatternF(pattern, repl string) func(string) string { return func(s string) string { return ReplacePattern(s, pattern, repl) } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/css/easyjson.go#L1471-L1475
func (v *SetStyleTextsParams) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoCss12(&r, v) return r.Error() }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/cxcore.go#L832-L834
func (seq *Seq) PopFront(element unsafe.Pointer) { C.cvSeqPopFront((*C.struct_CvSeq)(seq), element) }
https://github.com/256dpi/fire/blob/fa66e74352b30b9a4c730f7b8dc773302941b0fb/body_limiter.go#L17-L22
func NewBodyLimiter(w http.ResponseWriter, r *http.Request, n int64) *BodyLimiter { return &BodyLimiter{ Original: r.Body, ReadCloser: http.MaxBytesReader(w, r.Body, n), } }
https://github.com/tsuru/tsuru/blob/2f7fd515c5dc25a58aec80f0e497c49e49581b3e/auth/team.go#L118-L132
func processTags(tags []string) []string { if tags == nil { return nil } processedTags := []string{} usedTags := make(map[string]bool) for _, tag := range tags { tag = strings.TrimSpace(tag) if len(tag) > 0 && !usedTags[tag] { processedTags = append(processedTags, tag) usedTags[tag] = true } } return processedTags }
https://github.com/op/go-logging/blob/970db520ece77730c7e4724c61121037378659d9/logger.go#L180-L183
func (l *Logger) Fatalf(format string, args ...interface{}) { l.log(CRITICAL, &format, args...) os.Exit(1) }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/gen/writers/client.go#L54-L56
func (c *ClientWriter) WriteResourceHeader(name string, w io.Writer) { fmt.Fprintf(w, "/****** %s ******/\n\n", name) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/api/rafthttp/http.go#L78-L86
func newPipelineHandler(t *Transport, r Raft, cid types.ID) http.Handler { return &pipelineHandler{ lg: t.Logger, localID: t.ID, tr: t, r: r, cid: cid, } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/dom/easyjson.go#L6557-L6561
func (v CopyToReturns) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoDom74(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/generate/db/lex.go#L54-L64
func activeCriteria(filter []string) string { expr := "" for i, name := range filter { if i > 0 { expr += " && " } expr += fmt.Sprintf("criteria[%q] != nil", name) } return expr }
https://github.com/enaml-ops/enaml/blob/4f847ee10b41afca41fe09fa839cb2f6ade06fb5/generators/record.go#L6-L20
func (v *Record) StructName(i int, packagename string, properties []string) (structname string) { if i > 0 { currentNode := v.Slice[i-1] structname = FormatName(currentNode) if i > 1 { parentNames := v.FindAllParentsOfSameNamedElement(currentNode, properties) if len(parentNames) > 1 { structname = FormatName(v.Slice[i-2] + "_" + currentNode) } } } else { structname = FormatName(packagename + "_job") } return }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/github/client.go#L1520-L1523
func (c *Client) GetRepoLabels(org, repo string) ([]Label, error) { c.log("GetRepoLabels", org, repo) return c.getLabels(fmt.Sprintf("/repos/%s/%s/labels", org, repo)) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/shared/cancel/canceler.go#L27-L33
func (c *Canceler) Cancelable() bool { c.lock.Lock() length := len(c.reqChCancel) c.lock.Unlock() return length > 0 }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_lxc.go#L8913-L8916
func (c *containerLXC) Path() string { name := projectPrefix(c.Project(), c.Name()) return containerPath(name, c.IsSnapshot()) }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/image/docker_schema2.go#L94-L115
func (m *manifestSchema2) ConfigBlob(ctx context.Context) ([]byte, error) { if m.configBlob == nil { if m.src == nil { return nil, errors.Errorf("Internal error: neither src nor configBlob set in manifestSchema2") } stream, _, err := m.src.GetBlob(ctx, manifest.BlobInfoFromSchema2Descriptor(m.m.ConfigDescriptor), none.NoCache) if err != nil { return nil, err } defer stream.Close() blob, err := ioutil.ReadAll(stream) if err != nil { return nil, err } computedDigest := digest.FromBytes(blob) if computedDigest != m.m.ConfigDescriptor.Digest { return nil, errors.Errorf("Download config.json digest %s does not match expected %s", computedDigest, m.m.ConfigDescriptor.Digest) } m.configBlob = blob } return m.configBlob, nil }
https://github.com/hashicorp/raft/blob/773bcaa2009bf059c5c06457b9fccd156d5e91e7/api.go#L907-L912
func (r *Raft) LastContact() time.Time { r.lastContactLock.RLock() last := r.lastContact r.lastContactLock.RUnlock() return last }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/client/lxd_containers.go#L834-L904
func (r *ProtocolLXD) GetContainerFile(containerName string, path string) (io.ReadCloser, *ContainerFileResponse, error) { // Prepare the HTTP request requestURL, err := shared.URLEncode( fmt.Sprintf("%s/1.0/containers/%s/files", r.httpHost, url.QueryEscape(containerName)), map[string]string{"path": path}) if err != nil { return nil, nil, err } requestURL, err = r.setQueryAttributes(requestURL) if err != nil { return nil, nil, err } req, err := http.NewRequest("GET", requestURL, nil) if err != nil { return nil, nil, err } // Set the user agent if r.httpUserAgent != "" { req.Header.Set("User-Agent", r.httpUserAgent) } // Send the request resp, err := r.do(req) if err != nil { return nil, nil, err } // Check the return value for a cleaner error if resp.StatusCode != http.StatusOK { _, _, err := lxdParseResponse(resp) if err != nil { return nil, nil, err } } // Parse the headers uid, gid, mode, fileType, _ := shared.ParseLXDFileHeaders(resp.Header) fileResp := ContainerFileResponse{ UID: uid, GID: gid, Mode: mode, Type: fileType, } if fileResp.Type == "directory" { // Decode the response response := api.Response{} decoder := json.NewDecoder(resp.Body) err = decoder.Decode(&response) if err != nil { return nil, nil, err } // Get the file list entries := []string{} err = response.MetadataAsStruct(&entries) if err != nil { return nil, nil, err } fileResp.Entries = entries return nil, &fileResp, err } return resp.Body, &fileResp, err }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L7664-L7668
func (v DeleteCookiesParams) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork60(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/hooklift/govix/blob/063702285520a992b920fc1575e305dc9ffd6ffe/vm.go#L118-L135
func (v *VM) MemorySize() (uint, error) { var err C.VixError = C.VIX_OK memsize := C.VIX_PROPERTY_NONE err = C.get_property(v.handle, C.VIX_PROPERTY_VM_MEMORY_SIZE, unsafe.Pointer(&memsize)) if C.VIX_OK != err { return 0, &Error{ Operation: "vm.MemorySize", Code: int(err & 0xFFFF), Text: C.GoString(C.Vix_GetErrorText(err, nil)), } } return uint(memsize), nil }
https://github.com/xwb1989/sqlparser/blob/120387863bf27d04bc07db8015110a6e96d0146c/normalizer.go#L77-L85
func (nz *normalizer) WalkSelect(node SQLNode) (bool, error) { switch node := node.(type) { case *SQLVal: nz.convertSQLValDedup(node) case *ComparisonExpr: nz.convertComparison(node) } return true, nil }
https://github.com/TheThingsNetwork/go-utils/blob/aa2a11bd59104d2a8609328c2b2b55da61826470/errors/descriptor.go#L38-L49
func (err *ErrDescriptor) New(attributes Attributes) Error { if err.Code != NoCode && !err.registered { panic(fmt.Errorf("Error descriptor with code %v was not registered", err.Code)) } return &impl{ message: Format(err.MessageFormat, attributes), code: err.Code, typ: err.Type, attributes: attributes, } }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/layertree/easyjson.go#L1856-L1860
func (v EventLayerPainted) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoLayertree16(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdctl/ctlv3/command/role_command.go#L106-L117
func roleAddCommandFunc(cmd *cobra.Command, args []string) { if len(args) != 1 { ExitWithError(ExitBadArgs, fmt.Errorf("role add command requires role name as its argument")) } resp, err := mustClientFromCmd(cmd).Auth.RoleAdd(context.TODO(), args[0]) if err != nil { ExitWithError(ExitError, err) } display.RoleAdd(args[0], *resp) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/query/retry.go#L16-L33
func Retry(f func() error) error { // TODO: the retry loop should be configurable. var err error for i := 0; i < 5; i++ { err = f() if err != nil { logger.Debugf("Database error: %#v", err) if IsRetriableError(err) { logger.Debugf("Retry failed db interaction (%v)", err) time.Sleep(250 * time.Millisecond) continue } } break } return err }
https://github.com/ipfs/go-ipfs-api/blob/a1b28da48b3763f67654ec4cfcba5fcbfb3dfb32/shell.go#L477-L481
func (s *Shell) StatsBW(ctx context.Context) (*p2pmetrics.Stats, error) { v := &p2pmetrics.Stats{} err := s.Request("stats/bw").Exec(ctx, &v) return v, err }
https://github.com/gobuffalo/buffalo/blob/7f360181f4ccd79dcc9dcea2c904a4801f194f04/servers/listener.go#L29-L38
func UnixSocket(addr string) (*Listener, error) { listener, err := net.Listen("unix", addr) if err != nil { return nil, err } return &Listener{ Server: &http.Server{}, Listener: listener, }, nil }
https://github.com/llgcode/draw2d/blob/f52c8a71aff06ab8df41843d33ab167b36c971cd/draw2dpdf/gc.go#L331-L334
func (gc *GraphicContext) Scale(sx, sy float64) { gc.StackGraphicContext.Scale(sx, sy) gc.pdf.TransformScale(sx*100, sy*100, 0, 0) }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/db/images.go#L353-L390
func (c *Cluster) ImageGetFromAnyProject(fingerprint string) (int, *api.Image, error) { var create, expire, used, upload *time.Time // These hold the db-returned times // The object we'll actually return image := api.Image{} id := -1 arch := -1 // These two humongous things will be filled by the call to DbQueryRowScan outfmt := []interface{}{&id, &image.Fingerprint, &image.Filename, &image.Size, &image.Cached, &image.Public, &image.AutoUpdate, &arch, &create, &expire, &used, &upload} inargs := []interface{}{fingerprint} query := ` SELECT images.id, fingerprint, filename, size, cached, public, auto_update, architecture, creation_date, expiry_date, last_use_date, upload_date FROM images WHERE fingerprint = ? LIMIT 1` err := dbQueryRowScan(c.db, query, inargs, outfmt) if err != nil { if err == sql.ErrNoRows { return -1, nil, ErrNoSuchObject } return -1, nil, err // Likely: there are no rows for this fingerprint } err = c.imageFill(id, &image, create, expire, used, upload, arch) if err != nil { return -1, nil, errors.Wrapf(err, "Fill image details") } return id, &image, nil }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L4308-L4322
func NewOperationResult(code OperationResultCode, value interface{}) (result OperationResult, err error) { result.Code = code switch OperationResultCode(code) { case OperationResultCodeOpInner: tv, ok := value.(OperationResultTr) if !ok { err = fmt.Errorf("invalid value, must be OperationResultTr") return } result.Tr = &tv default: // void } return }
https://github.com/rightscale/rsc/blob/96079a1ee7238dae9cbb7efa77dd94a479d217bd/cm15/codegen_client.go#L2921-L2923
func (api *API) DatacenterLocator(href string) *DatacenterLocator { return &DatacenterLocator{Href(href), api} }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/emulation/easyjson.go#L1751-L1755
func (v *CanEmulateReturns) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} easyjsonC5a4559bDecodeGithubComChromedpCdprotoEmulation20(&r, v) return r.Error() }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/xdr/xdr_generated.go#L7152-L7161
func (u ScpStatementPledges) GetExternalize() (result ScpStatementExternalize, ok bool) { armName, _ := u.ArmForSwitch(int32(u.Type)) if armName == "Externalize" { result = *u.Externalize ok = true } return }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/api_cluster.go#L169-L199
func clusterPut(d *Daemon, r *http.Request) Response { req := api.ClusterPut{} // Parse the request err := json.NewDecoder(r.Body).Decode(&req) if err != nil { return BadRequest(err) } // Sanity checks if req.ServerName == "" && req.Enabled { return BadRequest(fmt.Errorf("ServerName is required when enabling clustering")) } if req.ServerName != "" && !req.Enabled { return BadRequest(fmt.Errorf("ServerName must be empty when disabling clustering")) } // Disable clustering. if !req.Enabled { return clusterPutDisable(d) } // Depending on the provided parameters we either bootstrap a brand new // cluster with this node as first node, or perform a request to join a // given cluster. if req.ClusterAddress == "" { return clusterPutBootstrap(d, req) } return clusterPutJoin(d, req) }
https://github.com/ianschenck/envflag/blob/9111d830d133f952887a936367fb0211c3134f0d/envflag.go#L88-L90
func Int64(name string, value int64, usage string) *int64 { return EnvironmentFlags.Int64(name, value, usage) }
https://github.com/go-opencv/go-opencv/blob/a4fe8ec027ccc9eb8b7d0797db7c76e61083f1db/opencv/highgui.go#L364-L374
func LoadImage(filename string, iscolor_ ...int) *IplImage { iscolor := CV_LOAD_IMAGE_COLOR if len(iscolor_) > 0 { iscolor = iscolor_[0] } name_c := C.CString(filename) defer C.free(unsafe.Pointer(name_c)) rv := C.cvLoadImage(name_c, C.int(iscolor)) return (*IplImage)(rv) }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/pkg/flags/urls.go#L41-L47
func (us *URLsValue) String() string { all := make([]string, len(*us)) for i, u := range *us { all[i] = u.String() } return strings.Join(all, ",") }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/pkg/blobinfocache/default.go#L61-L75
func DefaultCache(sys *types.SystemContext) types.BlobInfoCache { dir, err := blobInfoCacheDir(sys, getRootlessUID()) if err != nil { logrus.Debugf("Error determining a location for %s, using a memory-only cache", blobInfoCacheFilename) return memory.New() } path := filepath.Join(dir, blobInfoCacheFilename) if err := os.MkdirAll(dir, 0700); err != nil { logrus.Debugf("Error creating parent directories for %s, using a memory-only cache: %v", blobInfoCacheFilename, err) return memory.New() } logrus.Debugf("Using blob info cache at %s", path) return boltdb.New(path) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/config/tide.go#L477-L510
func (c Config) GetTideContextPolicy(org, repo, branch string) (*TideContextPolicy, error) { options := parseTideContextPolicyOptions(org, repo, branch, c.Tide.ContextOptions) // Adding required and optional contexts from options required := sets.NewString(options.RequiredContexts...) requiredIfPresent := sets.NewString(options.RequiredIfPresentContexts...) optional := sets.NewString(options.OptionalContexts...) // automatically generate required and optional entries for Prow Jobs prowRequired, prowRequiredIfPresent, prowOptional := BranchRequirements(org, repo, branch, c.Presubmits) required.Insert(prowRequired...) requiredIfPresent.Insert(prowRequiredIfPresent...) optional.Insert(prowOptional...) // Using Branch protection configuration if options.FromBranchProtection != nil && *options.FromBranchProtection { bp, err := c.GetBranchProtection(org, repo, branch) if err != nil { logrus.WithError(err).Warningf("Error getting branch protection for %s/%s+%s", org, repo, branch) } else if bp != nil && bp.Protect != nil && *bp.Protect && bp.RequiredStatusChecks != nil { required.Insert(bp.RequiredStatusChecks.Contexts...) } } t := &TideContextPolicy{ RequiredContexts: required.List(), RequiredIfPresentContexts: requiredIfPresent.List(), OptionalContexts: optional.List(), SkipUnknownContexts: options.SkipUnknownContexts, } if err := t.Validate(); err != nil { return t, err } return t, nil }
https://github.com/aphistic/gomol/blob/1546845ba714699f76f484ad3af64cf0503064d1/base.go#L372-L374
func (b *Base) Dbgf(msg string, a ...interface{}) error { return b.Debugf(msg, a...) }
https://github.com/iron-io/functions_go/blob/91b84f5bbb17095bf1c7028ec6e70a3dc06a5893/models/route.go#L118-L123
func (m *Route) validateFormatEnum(path, location string, value interface{}) error { if err := validate.Enum(path, location, value, routeTypeFormatPropEnum); err != nil { return err } return nil }
https://github.com/taskcluster/taskcluster-client-go/blob/ef6acd428ae5844a933792ed6479d0e7dca61ef8/codegenerator/model/api.go#L244-L253
func (entry *APIEntry) postPopulate(apiDef *APIDefinition) { if x := &entry.Parent.apiDef.schemaURLs; entry.Input != "" { entry.InputURL = tcurls.Schema(tcclient.RootURLFromEnvVars(), entry.Parent.ServiceName, entry.Input) *x = append(*x, entry.InputURL) } if x := &entry.Parent.apiDef.schemaURLs; entry.Output != "" { entry.OutputURL = tcurls.Schema(tcclient.RootURLFromEnvVars(), entry.Parent.ServiceName, entry.Output) *x = append(*x, entry.OutputURL) } }
https://github.com/pachyderm/pachyderm/blob/94fb2d536cb6852a77a49e8f777dc9c1bde2c723/src/client/pfs.go#L1258-L1279
func (c APIClient) Walk(repoName string, commitID string, path string, f WalkFn) error { fs, err := c.PfsAPIClient.WalkFile( c.Ctx(), &pfs.WalkFileRequest{File: NewFile(repoName, commitID, path)}) if err != nil { return grpcutil.ScrubGRPC(err) } for { fi, err := fs.Recv() if err == io.EOF { return nil } else if err != nil { return grpcutil.ScrubGRPC(err) } if err := f(fi); err != nil { if err == errutil.ErrBreak { return nil } return err } } }
https://github.com/ctripcorp/ghost/blob/9dce30d85194129b9c0ba6702c612f3b5c41d02f/pool/blockingPool.go#L55-L84
func (p *blockingPool) Get() (net.Conn, error) { //in case that pool is closed or pool.conns is set to nil conns := p.conns if conns == nil { return nil, ErrClosed } select { case conn := <-conns: if time.Since(conn.start) > p.livetime { if conn.Conn != nil { conn.Conn.Close() conn.Conn = nil } } if conn.Conn == nil { var err error conn.Conn, err = p.factory() if err != nil { conn.start = time.Now() p.put(conn) return nil, err } } conn.unusable = false return conn, nil case <-time.After(time.Second*p.timeout): return nil, ErrTimeout } }
https://github.com/enaml-ops/enaml/blob/4f847ee10b41afca41fe09fa839cb2f6ade06fb5/run/diffcmd.go#L43-L54
func (s *DiffCmd) Job(job string, w io.Writer) error { differ, err := diff.New(s.releaseRepo, s.release1, s.release2) if err != nil { return err } d, err := differ.DiffJob(job) if err != nil { return err } s.printDiffResult(w, d) return nil }
https://github.com/justinfx/gofileseq/blob/2555f296b4493d1825f5f6fab4aa0ff51a8306cd/exp/cpp/export/export.go#L308-L315
func FileSequence_Dirname(id FileSeqId) *C.char { fs, ok := sFileSeqs.Get(id) // caller must free string if !ok { return C.CString("") } return C.CString(fs.Dirname()) }
https://github.com/containers/image/blob/da9ab3561ad2031aeb5e036b7cf2755d4e246fec/docker/lookaside.go#L195-L202
func signatureStorageURL(base signatureStorageBase, manifestDigest digest.Digest, index int) *url.URL { if base == nil { return nil } url := *base url.Path = fmt.Sprintf("%s@%s=%s/signature-%d", url.Path, manifestDigest.Algorithm(), manifestDigest.Hex(), index+1) return &url }
https://github.com/google/go-cmp/blob/6f77996f0c42f7b84e5a2b252227263f93432e9b/cmp/report_reflect.go#L238-L259
func formatHex(u uint64) string { var f string switch { case u <= 0xff: f = "0x%02x" case u <= 0xffff: f = "0x%04x" case u <= 0xffffff: f = "0x%06x" case u <= 0xffffffff: f = "0x%08x" case u <= 0xffffffffff: f = "0x%010x" case u <= 0xffffffffffff: f = "0x%012x" case u <= 0xffffffffffffff: f = "0x%014x" case u <= 0xffffffffffffffff: f = "0x%016x" } return fmt.Sprintf(f, u) }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/table/iterator.go#L470-L472
func (s *ConcatIterator) Valid() bool { return s.cur != nil && s.cur.Valid() }
https://github.com/apparentlymart/go-rundeck-api/blob/2c962acae81080a937c350a5bea054c239f27a81/rundeck/project.go#L59-L63
func (c *Client) CreateProject(project *Project) (*Project, error) { p := &Project{} err := c.post([]string{"projects"}, nil, project, p) return p, err }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/velodrome/transform/plugins/state.go#L42-L45
func (s *StatePlugin) CheckFlags() error { s.states = NewBundledStates(s.desc) return nil }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/log/log.go#L234-L241
func (params *Query) Run(c context.Context) *Result { req, err := makeRequest(params, internal.FullyQualifiedAppID(c), appengine.VersionID(c)) return &Result{ context: c, request: req, err: err, } }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/util/net.go#L111-L134
func NetworkInterfaceAddress() string { ifaces, err := net.Interfaces() if err != nil { return "" } for _, iface := range ifaces { if shared.IsLoopback(&iface) { continue } addrs, err := iface.Addrs() if err != nil { continue } if len(addrs) == 0 { continue } addr, ok := addrs[0].(*net.IPNet) if !ok { continue } return addr.IP.String() } return "" }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/network/easyjson.go#L5287-L5291
func (v EventWebSocketHandshakeResponseReceived) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} easyjsonC5a4559bEncodeGithubComChromedpCdprotoNetwork41(&w, v) return w.Buffer.BuildBytes(), w.Error }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/taskqueue/taskqueue.go#L369-L402
func DeleteMulti(c context.Context, tasks []*Task, queueName string) error { taskNames := make([][]byte, len(tasks)) for i, t := range tasks { taskNames[i] = []byte(t.Name) } if queueName == "" { queueName = "default" } req := &pb.TaskQueueDeleteRequest{ QueueName: []byte(queueName), TaskName: taskNames, } res := &pb.TaskQueueDeleteResponse{} if err := internal.Call(c, "taskqueue", "Delete", req, res); err != nil { return err } if a, b := len(req.TaskName), len(res.Result); a != b { return fmt.Errorf("taskqueue: internal error: requested deletion of %d tasks, got %d results", a, b) } me, any := make(appengine.MultiError, len(res.Result)), false for i, ec := range res.Result { if ec != pb.TaskQueueServiceError_OK { me[i] = &internal.APIError{ Service: "taskqueue", Code: int32(ec), } any = true } } if any { return me } return nil }
https://github.com/ant0ine/go-json-rest/blob/ebb33769ae013bd5f518a8bac348c310dea768b8/rest/gzip.go#L96-L99
func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { hijacker := w.ResponseWriter.(http.Hijacker) return hijacker.Hijack() }
https://github.com/golang/appengine/blob/54a98f90d1c46b7731eb8fb305d2a321c30ef610/cmd/aebundler/aebundler.go#L168-L195
func synthesizeMain(tw *tar.Writer, appFiles []string) error { appMap := make(map[string]bool) for _, f := range appFiles { appMap[f] = true } var f string for i := 0; i < 100; i++ { f = fmt.Sprintf("app_main%d.go", i) if !appMap[filepath.Join(*rootDir, f)] { break } } if appMap[filepath.Join(*rootDir, f)] { return fmt.Errorf("unable to find unique name for %v", f) } hdr := &tar.Header{ Name: f, Mode: 0644, Size: int64(len(newMain)), } if err := tw.WriteHeader(hdr); err != nil { return fmt.Errorf("unable to write header for %v: %v", f, err) } if _, err := tw.Write([]byte(newMain)); err != nil { return fmt.Errorf("unable to write %v to tar file: %v", f, err) } return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/input/types.go#L260-L274
func (t *MouseType) UnmarshalEasyJSON(in *jlexer.Lexer) { switch MouseType(in.String()) { case MousePressed: *t = MousePressed case MouseReleased: *t = MouseReleased case MouseMoved: *t = MouseMoved case MouseWheel: *t = MouseWheel default: in.AddError(errors.New("unknown MouseType value")) } }
https://github.com/dgraph-io/badger/blob/6b796b3ebec3ff006fcb1b425836cd784651e9fd/db.go#L729-L736
func (db *DB) batchSet(entries []*Entry) error { req, err := db.sendToWriteCh(entries) if err != nil { return err } return req.Wait() }
https://github.com/mgutz/str/blob/968bf66e3da857419e4f6e71b2d5c9ae95682dc4/funcsPZ.go#L530-L534
func WrapHTMLF(tag string, attrs map[string]string) func(string) string { return func(s string) string { return WrapHTML(s, tag, attrs) } }
https://github.com/piotrkowalczuk/mnemosyne/blob/66d59c3c5b886e8e869915bb76257bcba4a47250/internal/storage/storagemock/storage.go#L17-L35
func (_m *Storage) Abandon(_a0 context.Context, _a1 string) (bool, error) { ret := _m.Called(_a0, _a1) var r0 bool if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { r0 = rf(_a0, _a1) } else { r0 = ret.Get(0).(bool) } var r1 error if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) } return r0, r1 }
https://github.com/opentracing/opentracing-go/blob/659c90643e714681897ec2521c60567dd21da733/mocktracer/mockspan.go#L259-L261
func (s *MockSpan) LogEvent(event string) { s.LogFields(log.String("event", event)) }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/cmd/mkbuild-cluster/main.go#L167-L170
func setAccount(account string) error { _, cmd := command("gcloud", "config", "set", "core/account", account) return cmd.Run() }
https://github.com/kubernetes/test-infra/blob/8125fbda10178887be5dff9e901d6a0a519b67bc/prow/plugins/approve/approvers/owners.go#L200-L220
func (o Owners) removeSubdirs(dirs sets.String) { canonicalize := func(p string) string { if p == "." { return "" } return p } for _, dir := range dirs.List() { path := dir for { if o.repo.IsNoParentOwners(path) || canonicalize(path) == "" { break } path = filepath.Dir(path) if dirs.Has(canonicalize(path)) { dirs.Delete(dir) break } } } }
https://github.com/etcd-io/etcd/blob/616592d9ba993e3fe9798eef581316016df98906/etcdserver/server.go#L1479-L1488
func (s *EtcdServer) Stop() { if err := s.TransferLeadership(); err != nil { if lg := s.getLogger(); lg != nil { lg.Warn("leadership transfer failed", zap.String("local-member-id", s.ID().String()), zap.Error(err)) } else { plog.Warningf("%s failed to transfer leadership (%v)", s.ID(), err) } } s.HardStop() }
https://github.com/lxc/lxd/blob/7a41d14e4c1a6bc25918aca91004d594774dcdd3/lxd/container_lxc.go#L1859-L1871
func (c *containerLXC) expandConfig(profiles []api.Profile) error { if profiles == nil && len(c.profiles) > 0 { var err error profiles, err = c.state.Cluster.ProfilesGet(c.project, c.profiles) if err != nil { return err } } c.expandedConfig = db.ProfilesExpandConfig(c.localConfig, profiles) return nil }
https://github.com/chromedp/cdproto/blob/d40c70bcdf242660a32f2eadf323662dd75378b5/page/types.go#L359-L369
func (t *CaptureScreenshotFormat) UnmarshalEasyJSON(in *jlexer.Lexer) { switch CaptureScreenshotFormat(in.String()) { case CaptureScreenshotFormatJpeg: *t = CaptureScreenshotFormatJpeg case CaptureScreenshotFormatPng: *t = CaptureScreenshotFormatPng default: in.AddError(errors.New("unknown CaptureScreenshotFormat value")) } }
https://github.com/stellar/go-stellar-base/blob/79c570612c0b461db178aa8949d9f13cafc2a7c9/build/change_trust.go#L31-L48
func (b *ChangeTrustBuilder) Mutate(muts ...interface{}) { for _, m := range muts { var err error switch mut := m.(type) { case ChangeTrustMutator: err = mut.MutateChangeTrust(&b.CT) case OperationMutator: err = mut.MutateOperation(&b.O) default: err = errors.New("Mutator type not allowed") } if err != nil { b.Err = err return } } }